Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How can I embed JavaScript function calls in a document.write statement?

Reply
Thread Tools

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

 
 
John
Guest
Posts: n/a
 
      11-16-2004
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.com/"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage(\'welcome\',\'\',\'../images/topnav/welcome_b_mydo
main-com.gif\',\'meet_the_team\',\'\',' + g_meet_the_team +
',\'rave_reviews\',\'\',' + g_rave_reviews +
',\'slide_show\',\'\',\'../images/topnav/slide_tour_a_mydomain-com.gif\',\'w
ho_we_are\',\'\',' +
',\'welcome_footer\',\'\',\'../images/topnav/welcome_sub_5_mydomain-com.gif\
',1)">');
document.write(<img src="../images/topnav/welcome_a_mydomain-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_swapImgRestore())
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


 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      11-16-2004


 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      11-16-2004
On Mon, 15 Nov 2004 20:00:41 -0500, John <> wrote:

[snip]

You've omitted the opening quote...

> document.write(<a title="Nice to meet you"


....here... ^

[snip]

> document.write(<img src="../images/topnav/welcome_a_mydomain-com.gif"


....and here. ^

[snip]

> name="welcome"></a></td>');


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.
 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How can you embed a function inside a replacement operator ? neilsolent Perl Misc 4 11-27-2007 03:44 PM
This function has an onClick event that calls a function that calls This function Bob Javascript 5 10-24-2006 04:11 PM
How override ALL function calls? (Is there a "function call function"?) seberino@spawar.navy.mil Python 2 08-01-2005 12:38 PM
How can I embed JavaScript function calls in a document.write statement? John Javascript 0 11-16-2004 01:01 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