473,503 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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
Jul 23 '05 #1
2 1872


Jul 23 '05 #2
On Mon, 15 Nov 2004 20:00:41 -0500, John <no****@domain.com> 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.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2521
by: Andy Fish | last post by:
Hi, I want to use an anchor tag to invoke some javascript and I've read that it's bad form to use <a href="javascript:foo()"> I've read endless usenet posts and hint sites on the net, they all...
27
2150
by: C Gillespie | last post by:
Dear All, Hopefully I have a simple problem. Basically, I just want to alter some text with JS. Here is some of my test code: <snip> <script type="text/javascript"> var tmp='a';
19
6854
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
4
3392
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
136
9201
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
6
5563
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
13
8272
by: John Smith | last post by:
I am using IE 6.0 from http://www.javaworld.com/javaworld/jw-07-1996/jw-07-javascript-p2.html I gather that "If you need to test a number of command lines, you can reduce the keystrokes by...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.