JavaScript syntax - Help

Discussion in 'Javascript' started by ArbolOne, Jun 6, 2009.

  1. ArbolOne

    ArbolOne Guest

    can anyone tell me what is wrong with this syntax?
    document.writeln('<bgsound src="' + soundfile +'" loop=1> +
    volume=v>');

    TIA
     
    ArbolOne, Jun 6, 2009
    #1
    1. Advertising

  2. ArbolOne

    VK Guest

    On Jun 7, 2:26 am, ArbolOne <> wrote:
    > can anyone tell me what is wrong with this syntax?


    1) Quotes and 2) resulting HTML tag format?

    > document.writeln('<bgsound src="' + soundfile +'" loop=1> + volume=v>');

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    document.writeln('<bgsound src="'.concat(
    soundfile,
    '" loop=1',
    ' volume=',
    v,
    '>'
    ));
     
    VK, Jun 7, 2009
    #2
    1. Advertising

  3. VK wrote:
    > On Jun 7, 2:26 am, ArbolOne <> wrote:
    >> can anyone tell me what is wrong with this syntax?

    >
    > 1) Quotes and 2) resulting HTML tag format?


    There is no "HTML tag format", idiot.

    >> document.writeln('<bgsound src="' + soundfile +'" loop=1> + volume=v>');

    > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >
    > document.writeln('<bgsound src="'.concat(
    > soundfile,
    > '" loop=1',
    > ' volume=',
    > v,
    > '>'
    > ));


    Complete utter nonsense to call concat() where a simple proper concatenation
    would have sufficed.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jun 7, 2009
    #3
  4. ArbolOne wrote:
    > can anyone tell me what is wrong with this syntax?
    > document.writeln('<bgsound src="' + soundfile +'" loop=1> +
    > volume=v>');


    Everything.

    1. Use document.write() instead.

    2. The `bgsound' element is proprietary, obsolete, and unnecessary.
    You must have been getting this from an obsolete or erroneous
    tutorial or Web site.

    3. Suppose the value of `soundfile' is "foo", this would generate

    <bgsound src="foo" loop=1> + volume=v>

    Probably you are (not) looking for this:

    document.write('<bgsound src="' + soundfile + '" loop=1'
    + 'volume="' + v + '">');

    Again, that is recommended against from the HTML point of view. Use instead:

    document.write([
    '<object data="' + soundfile + '">',
    ' <param name="FileName" value="' + soundfile + '">',
    ' <param name="URL" value="' + soundfile + '">',
    ' <param name="playCount" value="1">',
    ' <param name="volume" value="' + v + '">',
    '<\/object>'
    ].join("\n"));

    The `param' elements should take care of Microsoft Media Player 9+ support,
    but you might have to branch with a `clsid' attribute for the `object'
    element in order to avoid ActiveX warnings (see
    <http://msdn.microsoft.com/en-us/library/aa393200(VS.85).aspx>). The only
    alternative I know is the proprietary `embed' element.

    That said, avoid using background sounds/music on Web sites as they will
    likely annoy users. Notable exceptions include those where the background
    sound or music is probably important for user experience, such as the proper
    background sound in a simulation or the newest title playing on a music
    group's Web site. Be sure to provide a way to shut it all sounds off, though.


    HTH

    PointedEars
     
    Thomas 'PointedEars' Lahn, Jun 7, 2009
    #4
  5. ArbolOne

    ArbolOne Guest

    Thanks soooo much, it worked perfectly!
     
    ArbolOne, Jun 7, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gabriele renzi
    Replies:
    2
    Views:
    220
    gabriele renzi
    Dec 31, 2005
  2. Ken Bloom
    Replies:
    3
    Views:
    223
  3. Good Night Moon
    Replies:
    9
    Views:
    290
    Rick DeNatale
    Jul 25, 2007
  4. Jacob Grover
    Replies:
    5
    Views:
    325
    Jacob Grover
    Jul 18, 2008
  5. Mark Richards
    Replies:
    3
    Views:
    323
    Tad McClellan
    Nov 18, 2007
Loading...

Share This Page