Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    why i can't parse google ads through javascript

    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>';

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    865
    Thanks
    7
    Thanked 29 Times in 28 Posts
    You should have received some code from google to past into your website once you have signed up.

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    try this:



    Code:
    <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>");
    </script>
    </div>
    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.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #4
    New Coder
    Join Date
    Dec 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by naeembhatti; 11-13-2006 at 10:49 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •