View Full Version : javascript inside document.write

07-17-2007, 09:42 AM
Hello everyone,

I have to write this html/javascript code inside document.write().

<table width="995" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<td width="14" rowspan="3"><img src="/imagenes/publi/CintPubli_Vert_01.gif" width="14" height="100"></td>
<td background="/imagenes/publi/SuperBanner_PxSup.gif"><img src="/imagenes/espacio.gif" width="728" height="4"></td>
<td background="/imagenes/publi/SuperBanner_PxSup.gif"><img src="/imagenes/espacio.gif" width="4" height="4"></td>
<td width="728"><script language="JavaScript" type="text/javascript">
document.write('<script language="JavaScript" src="http://ad.es.doubleclick.net/adj/motociclismo.tsv/portada;sz=468x60;sect=;ptile=1;ord=' + ord + '?" type="text/javascript"><\/script>');</script><noscript><a
href="http://ad.es.doubleclick.net/jump/motociclismo.tsv/portada;sz=468x60;sect=;ptile=1;ord=123456789?" target="_blank"><img
src="http://ad.es.doubleclick.net/ad/motociclismo.tsv/portada;sz=468x60;sect=;ptile=1;ord=123456789?" width="468" height="60" border="0" alt="banner"></a></noscript></td>
<td background="/imagenes/publi/Px_grisSB.gif"><img src="/imagenes/espacio.gif" width="253" height="4"></td>
<td background="/imagenes/publi/SuperBanner_Pxinf.gif"><img src="/imagenes/espacio.gif" width="728" height="5"></td>
<td background="/imagenes/publi/SuperBanner_Pxinf.gif"><img src="/imagenes/espacio.gif" width="4" height="4"></td>
<tr bgcolor="#ffffff">
<td colspan="3"><img src="/imagenes/espacio.gif" width="20" height="8"></td>

I have trying everything, but i am not able to make it work.

Can someone please help me? Thanks in advance

07-17-2007, 10:47 AM
This is what i tried, but it does not work. I canīt see the banner (js include) inside the <td>:

<script language="JavaScript" type="text/javascript">
function writeJS(){
var str='';
str+='<table width="995" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">';
str+=' <tr> ';
str+=' <td width="14" rowspan="3"><img src="\/imagenes\/publi\/CintPubli_Vert_01.gif" width="14" height="100"><\/td>';
str+=' <td background="\/imagenes\/publi\/SuperBanner_PxSup.gif"><img src="\/imagenes\/espacio.gif" width="728" height="4"><\/td>';
str+=' <td background="\/imagenes\/publi\/SuperBanner_PxSup.gif"><img src="\/imagenes\/espacio.gif" width="4" height="4"><\/td>';
str+=' <\/tr>';
str+=' <tr>';
str+=' <td width="728"><script language="JavaScript" type="text\/javascript">';
str+=' ord=Math.random()*10000000000000000;';
str+=' document.write(\'<script language="JavaScript" src="http:\/\/ad.es.doubleclick.net\/adj\/motociclismo.tsv\/portada;sz=468x60;sect=;ptile=1;ord=\' + ord + \'?" type="text\/javascript"><\/script>\');<\/script><noscript><a ';
str+=' href="http:\/\/ad.es.doubleclick.net\/jump\/motociclismo.tsv\/portada;sz=468x60;sect=;ptile=1;ord=123456789?" target="_blank"><img ';
str+=' src="http:\/\/ad.es.doubleclick.net\/ad\/motociclismo.tsv\/portada;sz=468x60;sect=;ptile=1;ord=123456789?" width="468" height="60" border="0" alt="banner"><\/a><\/noscript><\/td>';
str+=' <td background="\/imagenes\/publi\/Px_grisSB.gif"><img src="\/imagenes\/espacio.gif" width="253" height="4"><\/td>';
str+=' <\/tr>';
str+=' <tr>';
str+=' <td background="\/imagenes\/publi\/SuperBanner_Pxinf.gif"><img src="\/imagenes\/espacio.gif" width="728" height="5"><\/td>';
str+=' <td background="\/imagenes\/publi\/SuperBanner_Pxinf.gif"><img src="\/imagenes\/espacio.gif" width="4" height="4"><\/td>';
str+=' <\/tr>';
str+=' <tr bgcolor="#ffffff">';
str+=' <td colspan="3"><img src="\/imagenes\/espacio.gif" width="20" height="8"><\/td>';
str+=' <\/tr>';

Any idea? thanks again

07-18-2007, 07:16 AM
Can someone help me, please? I am still stuck.

Thanks in advance

07-19-2007, 07:39 AM
No ideas? I keep trying with this, but without any luck at the moment...please help.

07-19-2007, 07:46 AM
The reason you may not be getting responses because this a request that makes absolutely no sense. Why must you use document.write? Explain that to us.

rnd me
07-19-2007, 07:53 AM
The reason you may not be getting responses because this a request that makes absolutely no sense. Why must you use document.write? Explain that to us.

he doesn't need to explain/justify himself, he just needs his question answered.

the problem is writing the text for a script tag:

document.write(\'<script language="Jav...

//needs to be like:
document.write(\'<sc\' + \'ript language="Jav...

//or possibly like: (i got a little lost...)
document.write(\'<sc' + 'ript language="Jav...

you may or may not need to break up the end tags as well. probably not a bad idea...

the contiguous, though quoted script tag is accidentally parsed by the browser as the place to start a new script, not just another string...

hope this helps.

07-19-2007, 07:59 AM
he doesn't need to explain/justify himself, he just needs his question answered.
You may think so but keep your opinions to yourself thanks. The reason I asked him to is because this really seems like an assignment. Usually assignments require that you HAVE to use something. So if this is an assignment, thanks for doing his homework for him. :thumbsup:

07-19-2007, 08:04 AM
It is not an assignment, believe me. I just thought in document.write because i have no experience in javascript at all, but i can do it in any way.

Thanks anyway, i will solve it sooner or later.