How can I embed JavaScript function calls in a document.write statement?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    How can I embed JavaScript function calls in a document.write statement?

    Hi,
    I am getting syntax errors in my JavaScript code, code snippet as follows
    (between my <script></script> tags:

    document.write( <a title="Nice to meet you" href="http://www.mydomain.co m/"
    onmouseout="MM_ swapImgRestore( )"
    onmouseover="MM _swapImage(\'we lcome\',\'\',\' ../images/topnav/welcome_b_mydo
    main-com.gif\',\'mee t_the_team\',\' \',' + g_meet_the_team +
    ',\'rave_review s\',\'\',' + g_rave_reviews +
    ',\'slide_show\ ',\'\',\'../images/topnav/slide_tour_a_my domain-com.gif\',\'w
    ho_we_are\',\'\ ',' +
    ',\'welcome_foo ter\',\'\',\'../images/topnav/welcome_sub_5_m ydomain-com.gif\
    ',1)">');
    document.write( <img src="../images/topnav/welcome_a_mydom ain-com.gif"
    width="97" height="24" alt="Nice to meet you" border="0"
    name="welcome"> </a></td>');

    I *think* it's because I have function calls (e.g. MM_swapImgResto re())
    within the document.write statement. These calls pertain to my rollover
    functions which are declared prior. Is there a way to do this?

    Thanks,
    Don


  • John

    #2
    Sorry for multiple posts - Outlook Express went nuts ~



    Comment

    • Michael Winter

      #3
      Re: How can I embed JavaScript function calls in a document.write statement?

      On Mon, 15 Nov 2004 20:00:41 -0500, John <nospam@domain. com> wrote:

      [snip]

      You've omitted the opening quote...
      [color=blue]
      > document.write( <a title="Nice to meet you"[/color]

      ....here... ^

      [snip]
      [color=blue]
      > document.write( <img src="../images/topnav/welcome_a_mydom ain-com.gif"[/color]

      ....and here. ^

      [snip]
      [color=blue]
      > name="welcome"> </a></td>');[/color]

      Those closing tags should be written:

      <\/a><\/td>

      within that string. User agents are allowed to treat </ within a SCRIPT
      element as the closing tag for that element.

      By the way, please don't allow your news reader to automatically wrap
      code. No-one will be able to copy your code and run it as they have to fix
      all of the inserted line breaks. Instead, manually wrap to 80 characters
      at the very most. It's laborious, but it's in your interest.

      [snip]

      Mike

      --
      Michael Winter
      Replace ".invalid" with ".uk" to reply by e-mail.

      Comment

      Working...