View Full Version : why i can't parse google ads through javascript

Nov 11th, 2006, 09:46 AM
i have a div in which i am willing to print google ads, it alerts everything fine but it is not showing any thing even if u use document.write(google ads); it does not print any thing my code is here

y=document.getElementById('display_record');//setTimeout("y.style.display ='block'",50000);
y.style.display ='block';
y.innerHTML = '<p><script type="text/javascript"><!-- google_ad_client = "pub-8412861453096424"; google_ad_width = 468; google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image"; google_ad_channel ="8021588331";//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js "></script></p>';

Nov 11th, 2006, 05:40 PM
You should have received some code from google to past into your website once you have signed up.

Nov 12th, 2006, 05:02 AM
try this:

<div id=display_record>
<script type=text/javascript>
document.write("<p><script type="+"'text/javascript'> google_ad_client = 'pub-8412861453096424'; google_ad_width = 468; google_ad_height = 60;google_ad_format = '468x60_as';google_ad_type = 'text_image'; google_ad_channel ='8021588331';</"+"script><script type="+"'text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></"+"script></p>");

any script inserted with innerHTMl is not recognized a script. weird, i know, but its not.

think of it this way:

the <script> and </script> tags defines script right? well the only time the browser reads what is between theses two tags is when the page first loads. then and only then is the script loaded into the browsers cache/memory. which is where the script is being run from.

using document.write() on the other hand writes the script into the page as it is being loaded, therefore the browser sees it and stores it as script.

Nov 13th, 2006, 10:33 AM
thank you brandonH but if i have to use it for innerHTM then what should i do? actually i am using javascipt to get record from php and then display it how can i display them now? because i want to display records with in the page while document.write takes it to new page and then it display the record.