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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With Syntax..Please

Status
Not open for further replies.

abraxas

Programmer
Jan 15, 2001
75
AU
This is the LAST stretch of the &quot;Browser Cache Busting&quot; exercise which has been given to me in the last week. Meta Tags, Twin <BODY> statements and other suggestions, all with good intentions, have not worked.

This is the fragment that will work no matter how a clients browser cache is configured. (Thanks dang65)
frag1.
<TD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
document.write('<A HREF=&quot;/cgi-bin/myscript.pl?Dummy=' + (new Date()).getTime() + '&quot;>Link Text Here</A>')
</SCRIPT>
</TD>

After five hours of trying to fit this sideways into a RollOver image statement (frag2) and trying to understand what ' & &quot; mean to a browser I realised I was not making much progress.

frag2.
<a href=&quot;/cgi-jeanwarehouse/viewcart.pl&quot; onMouseOut=&quot;MM_swapImgRestore()&quot; onMouseOver=&quot;MM_swapImage('Image20','','toolbar/tb1d.jpg',1)&quot;>
<img name=&quot;Image20&quot; src=&quot;toolbar/tb1u.jpg&quot;></a>

Yes, those are DW3 js function calls.
Could anyone please offer a suggestion on how to combine frag1 with frag2 OR maybe some web resource that adequately explains (to the javascript lay person) what ' & &quot; actually do or don't?

Many thanks to you all
abraxas
 
Single ( ' ) and double ( &quot; ) quotes in JavaScript function identically and have to be balanced. You need more levels of quotes. JavaScript let's you do this by &quot;escaping&quot; quotes inside quotes by inserting a backslash ( \ ) character before it. For instance:

var foo = &quot;This is some \&quot;quoted text\&quot; to demo escaping.&quot;;

This is totally legal JavaScript. Basically what this gives you is the use of two more inner levels of quotes.

For you this would mean doing something like this:

document.write('<A HREF=&quot;/cgi-bin/myscript.pl?Dummy=' +
(new Date()).getTime() +
' onMouseOver=&quot;swapImage(\'img2\',\'\',\'img2.jpg\');&quot;' +
'&quot;>Link Text Here</A>')

Pretty freakin' ugly, huh?

The other option would be to throw all (or some anyway) of those string literals into variables and concatenated them inline.

Hope this helps.
/johnny
 
Johnny,
Remember ASCII's interperation of line noise? Harkens to days long past.

Thank you for your the advice, I'll start &quot;translating&quot; right away and let you know.
Kind regards
abraxas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top