Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using " ' makrs 1

Status
Not open for further replies.

GP

IS-IT--Management
Jan 14, 2002
61
GB
Hello

I am writing some code to generate an HTML page which has a hyperlink to another javascript function, with the following code:

document.write(a + 1, '. <a href=&quot;javascript:eek:penImage(&quot;../images/bab072.jpg&quot;)>', os[0], '</a>', os[2], ' <img src=&quot;../images/', os[4], '&quot; width=61 height=46> ');

The code runs and shows the text and image on screen however the hyperlink is truncated after the first (, - so the link is javascript:eek:penImage(

How do I use the quoation marks to get the full string of javascript:eek:penImage(&quot;../images/bab072.jpg&quot;)
 
What's with all the commas (,)?

document.write takes a string... therefore, you should have something like:
a + &quot; text &quot; + b + &quot; more text&quot; as a parameter.

document.write(a + &quot;<a href='javascript:eek:penImage(\&quot;../images/bab072.jpg\&quot;)'>&quot; + os[0] + &quot;</a>&quot; + os[2] + &quot;<img src=\&quot;../images/&quot; + os[4] + &quot;\&quot; width=61 height=46>&quot;);

You need to match up your single and double quotes. If you start with a double quote, and need to output a double quote, use the \&quot; to escape it.

Pete.


Lotus Notes Web Developer / Aptrix (LWWCM) Consultant
w: e: Pete.Raleigh(at)lclimited.co.uk
 

document.write is quite happy with commas, Pete.

Instead of +, which passes one string to the function, you can pass a comma-separated list.

 
theboyhope,

Yes - as weird as it is, all the newer browsers don't seem to mind the comma-delimited syntax.

Which is weird, IMHO, as all the documentation I've read, and reference books I've got open here, all say that it takes 1 parameter only - a string.

Very strange indeed. I wonder if the comma-delimited syntax validates to HTML/XHTML strict standards at all?

Dan
 
Cool, I stand corrected.

Guess, I've never had a need to use comma-separated lists. I generally like to be able to &quot;alert()&quot; a string to debug it, and an &quot;alert()&quot; statement will only output the first item in a comma-separated list (I think).

I've learnt 2 things in 2 days. :)

Pete.


Lotus Notes Web Developer / Aptrix (LWWCM) Consultant
w: e: Pete.Raleigh(at)lclimited.co.uk
 

What's javascript document.write() syntax got to do with XHTML validation?
 

Oooh good point - it's Javascript, and therefore doesn't have anything to do with HTML/XHTML validation.

Don't know what I was thinking ;o)

Dan
 
wartookman

I gave you the vote becuase you typed out the code for me which I copied and pasted and worked first time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top