Help Please!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Franklin P Patchey

    Help Please!

    I don't know anything about Javascript, but a little about standard HTML.

    I have created a website and have set the homepage to automatically play a
    sound file on opening.

    What I would like is for a random sound file (from my "audio" directory) to
    be played instead of the same one each time you visit.

    Can this be done and if so can someone please supply me with the (or an
    example) of code?.........


  • Ivo

    #2
    Re: Help Please!

    "Franklin P Patchey" <REMOVETHIS1010 01@talk21.com> wrote in message
    news:bl7p1e$te$ 1@newsg1.svr.po l.co.uk...[color=blue]
    > I don't know anything about Javascript, but a little about standard HTML.
    >
    > I have created a website and have set the homepage to automatically play a
    > sound file on opening.
    >
    > What I would like is for a random sound file (from my "audio" directory)[/color]
    to[color=blue]
    > be played instead of the same one each time you visit.
    >
    > Can this be done and if so can someone please supply me with the (or an
    > example) of code?.........
    >[/color]

    Please use descriptive subject lines.
    Yes, it can be done. One way would be to put the names of the files in an
    array, use Math.random()* the length of the array to randomly select a file,
    and document.write or manipulate the DOM to embed it.
    To find out more about what an array is etc., read this newsgroup, the
    multitude of websites about javascript and ask Google. The more you tell us
    about what you have tried, the more specific our help can be.
    HTH
    Ivo


    Comment

    • Ivo

      #3
      Re: random sound file //was: Help Please!

      "Franklin P Patchey" <REMOVETHIS1010 01@talk21.com> wrote in message
      news:bl7p1e$te$ 1@newsg1.svr.po l.co.uk...[color=blue]
      > I don't know anything about Javascript, but a little about standard HTML.
      >
      > I have created a website and have set the homepage to automatically play a
      > sound file on opening.
      >
      > What I would like is for a random sound file (from my "audio" directory)[/color]
      to[color=blue]
      > be played instead of the same one each time you visit.
      >
      > Can this be done and if so can someone please supply me with the (or an
      > example) of code?.........
      >[/color]

      Please use descriptive subject lines.
      Yes, it can be done. One way would be to put the names of the files in an
      array, use Math.random()* the length of the array to randomly select a file,
      and document.write or manipulate the DOM to embed it.
      To find out more about what an array is etc., read this newsgroup, the
      multitude of websites about javascript and ask Google. The more you tell us
      about what you have tried, the more specific our help can be.
      HTH
      Ivo



      Comment

      • Dr John Stockton

        #4
        Re: Help Please!

        JRS: In article <bl7p1e$te$1@ne wsg1.svr.pol.co .uk>, seen in
        news:comp.lang. javascript, Franklin P Patchey
        <REMOVETHIS1010 01@talk21.com> posted at Sun, 28 Sep 2003 23:57:41 :-[color=blue]
        >I don't know anything about Javascript, but a little about standard HTML.
        >
        >I have created a website and have set the homepage to automatically play a
        >sound file on opening.[/color]

        That will not work on systems which, like mine, have sound switched off.
        It will also annoy those who were expecting to be able to brows the web
        in peace and quiet, or while listening to their own choice of music.

        Sound should only be played when the potential hearer actually wants it.

        --
        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
        <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

        Comment

        Working...