Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > JavaScript syntax - Help

Reply
Thread Tools

JavaScript syntax - Help

 
 
ArbolOne
Guest
Posts: n/a
 
      06-06-2009
can anyone tell me what is wrong with this syntax?
document.writeln('<bgsound src="' + soundfile +'" loop=1> +
volume=v>');

TIA
 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      06-06-2009
On Jun 7, 2:26*am, ArbolOne <Arbol...@gmail.com> 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,
'>'
));

 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      06-06-2009
VK wrote:
> On Jun 7, 2:26 am, ArbolOne <Arbol...@gmail.com> 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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      06-06-2009
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
 
Reply With Quote
 
ArbolOne
Guest
Posts: n/a
 
      06-07-2009
Thanks soooo much, it worked perfectly!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax Checker that's better than the normal syntax checker Jacob Grover Ruby 5 07-18-2008 05:07 AM
Syntax error? What syntax error? Assignment fo default values? Mark Richards Perl Misc 3 11-18-2007 05:01 PM
Syntax bug, in 1.8.5? return not (some expr) <-- syntax error vsreturn (not (some expr)) <-- fine Good Night Moon Ruby 9 07-25-2007 04:51 PM
[ANN] SqlStatement 1.0.0 - hide the syntax of SQL behind familiarruby syntax Ken Bloom Ruby 3 10-09-2006 06:46 PM
Syntax highligth with textile: Syntax+RedCloth ? gabriele renzi Ruby 2 12-31-2005 02:44 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57