It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Javascript var inside document.write

Javascript var inside document.write

Postby cthood on Sat Mar 17, 2007 8:28 pm

I have this code which is dynamically generated from an ad server:

Code: Select all
document.write ('<script type="text/javascript"> var introclip =\n');
document.write ('"http://oascentral.domain.com/RealMedia/ads/adstream_lx.ads/domain.com/domain/home.do/2013086587/Frame1/domain/co/4151461/34316665653032353435666332393430"; </script> \n');
document.write ('<img src="http://bbeplayer.com/Tracking/V3/Instream/Impression/?0|528|4348|2044|513|869|http%3A//ad.doubleclick.net/ad/N2870.CoCo/B1847568.21%3Bsz%3D1x1%3Bord%3D%5Btimestamp%5D%3F|BBEEND|" border=0>');


I would like to be able to read the var introclip and use it somewhere else in my script or page. I can't seem to be able to read the variable at all though. Any thoughts?

Thanks.
cthood
 
Posts: 0
Joined: Sat Mar 17, 2007 8:23 pm

Postby sachav on Sun Mar 18, 2007 2:21 pm

That's because you have an incorrect character.
See at line 2-- the last word
It says "</script>"
The browser thinks that it's the end of the script there, so you would have to put an antislash in front of the / so the browser doesn't count it as the end of the script.
So when done it would be:
Code: Select all
document.write ('<script type="text/javascript"> var introclip =\n');
document.write ('"http://oascentral.domain.com/RealMedia/ads/adstream_lx.ads/domain.com/domain/home.do/2013086587/Frame1/domain/co/4151461/34316665653032353435666332393430"; <\/script> \n');
document.write ('<img src="http://bbeplayer.com/Tracking/V3/Instream/Impression/?0|528|4348|2044|513|869|http%3A//ad.doubleclick.net/ad/N2870.CoCo/B1847568.21%3Bsz%3D1x1%3Bord%3D%5Btimestamp%5D%3F|BBEEND|" border=0>');


And just put a code to read the variable:
Code: Select all
alert(introclip)


And you're done!
sachav
 
Posts: 32
Joined: Sat Mar 03, 2007 3:40 pm


Who is online

Users browsing this forum: No registered users and 6 guests