use <script> inside function ?

Discussion in 'Javascript' started by bunch92, Aug 2, 2005.

  1. bunch92

    bunch92 Guest

    Hi,
    I am stuck with ideas guys ....

    Can someone please tell me what I did wrong in the code below ? I think
    it might be the <script> tag inside the function ?

    Thank you


    <SCRIPT LANGUAGE="JavaScript">
    function playasound(thesound,thename,themethod)
    {
    if (themethod = 'W' || themethod = 'M' ){
    var s=parent.pagebas.document;
    s.open();
    s.write('<html><head></head><body bgcolor="#009999"
    text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
    marginheight="0">');
    s.write('<div align="center"><TABLE align="center" BORDER="0"
    CELLPADDING="0" CELLSPACING="0" WIDTH="520"><TR><TD
    width="400" bgcolor="#000000">');
    s.write('<div align="center"><font color="#FFFFFF" face="Arial,
    Helvetica, sans-serif" size="-2">');
    s.write('Now loading and playing .... <i>',thename,'</i> .....
    </font>');
    s.write('<embed src="',thesound,'" height="20" width="100" hidden
    autoplay="true">');
    s.write('</embed></div></TD></TR></TABLE></div></body></html>');
    s.close();
    }
    else if (themethod = 'X' || themethod = 'N'){
    var s=parent.pagebas.document;
    s.open();
    s.write('<html><head></head><body bgcolor="#009999"
    text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
    marginheight="0">');
    s.write('<div align="center"><TABLE align="center" BORDER="0"
    CELLPADDING="0" CELLSPACING="0" WIDTH="520"><TR><TD
    width="400" bgcolor="#000000">');
    s.write('<div align="center"><font color="#FFFFFF" face="Arial,
    Helvetica, sans-serif" size="-2">');
    s.write('Now loading and playing .... <i>',thename,'</i> .....
    </font>');
    s.write('<SCRIPT LANGUAGE="JavaScript">
    s.location.href="',thesound,'" </script>');
    s.write('</div></TD></TR></TABLE></div></body></html>');
    s.close();
    }
    }
    </SCRIPT>
     
    bunch92, Aug 2, 2005
    #1
    1. Advertising

  2. bunch92

    bunch92 Guest

    bunch92 <> wrote in
    news:Xns96A68A2F315F7bunch92yahoofr@213.123.26.234:

    > Hi,
    > I am stuck with ideas guys ....
    >


    Got it ...
    I needed <\/script>
     
    bunch92, Aug 2, 2005
    #2
    1. Advertising

  3. bunch92

    RobG Guest

    bunch92 wrote:
    > Hi,
    > I am stuck with ideas guys ....
    >
    > Can someone please tell me what I did wrong in the code below ? I think
    > it might be the <script> tag inside the function ?
    >
    > Thank you
    >
    >
    > <SCRIPT LANGUAGE="JavaScript">


    Language is depreciated, type is required.

    <script type="text/javascript">

    > function playasound(thesound,thename,themethod)
    > {
    > if (themethod = 'W' || themethod = 'M' ){


    Did you really mean assignment above or is evaluation required?

    if (themethod == 'W' || themethod == 'M' ){

    That is why it is often recommended to write comparisons with string
    literals with the string on the left so that assignment will cause an
    error rather than always be true:

    if ( 'W' == themethod || 'M' == themethod ){

    Otherwise the else statement will never be executed.

    [...]

    > else if (themethod = 'X' || themethod = 'N'){


    else if ( 'X' == themethod || 'N' == themethod ){

    [...]

    --
    Rob
     
    RobG, Aug 2, 2005
    #3
  4. bunch92

    bunch92 Guest

    RobG <> wrote in news:42ef797f$0$11941$5a62ac22@per-
    qv1-newsreader-01.iinet.net.au:

    > Language is depreciated, type is required.
    > <script type="text/javascript">
    >
    > [...]
    >
    > if ( 'W' == themethod || 'M' == themethod ){
    >



    Thank you very much for this.
    btw .. I meant evaluation, and will use your technique from now on.
     
    bunch92, Aug 2, 2005
    #4
  5. Douglas Crockford, Aug 2, 2005
    #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. David Dorward
    Replies:
    1
    Views:
    2,136
    Isofarro
    Jun 28, 2003
  2. Sur
    Replies:
    4
    Views:
    196
  3. J M
    Replies:
    2
    Views:
    115
    Tad McClellan
    Nov 6, 2004
  4. Replies:
    20
    Views:
    750
    Gunnar Hjalmarsson
    Jan 18, 2005
  5. cartercc
    Replies:
    7
    Views:
    129
    cartercc
    Oct 3, 2008
Loading...

Share This Page