470,600 Members | 1,480 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,600 developers. It's quick & easy.

Javascript of Google inside my javascript file

Good Morning,
I would want to insert the javascript of google adsense in my site,
here it is :

<script type="text/javascript"><!--
google_ad_client = "pub-4902392511135327";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
the problem is that I want to insert it inside a javascript file I
already use in a way that I've not to insert it in every page, how can
I do this, in expecially way, how can i formulate the

<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

when I am inside another javascript file ???

Thanks

Ing. Antonio D'Ottavio
Jul 23 '05 #1
3 1814
Ivo
"Antonio" wrote
Good Morning,
I would want to insert the javascript of google adsense in my site,
here it is :

<script type="text/javascript"><!--
google_ad_client = "pub-4902392511135327";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

the problem is that I want to insert it inside a javascript file I
already use in a way that I've not to insert it in every page, how


var x=document.createElement('script');
x.src="http://pagead";

I think you can only create elements after the initial onload event has
fired (and only on newer browsers), so put it in a function.
To include the file even the before load, make an empty script tag the first
in each document and set document.srcipts[0].src explicitly in your own .js
file (IE only I think).
HTH
Ivo
Jul 23 '05 #2
I made this :

function InserisciFooter()
{
document.write('<img src="' + base + 'images/barraFooter.png"
width="750" align="center">');

google_ad_client = "pub-4902392511135327";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
google_ad_type = "text_image";
google_color_border = ["B4D0DC","A8DDA0","578A24"];
google_color_bg = ["ECF8FF","EBFFED","CCFF99"];
google_color_link = ["0000CC","0000CC","00008B"];
google_color_url = ["008000","008000","00008B"];
google_color_text = ["6F6F6F","6F6F6F","000000"];
var x=document.createElement('script');
x.src="http://pagead2.googlesyndication.com/pagead/show_ads.js";
};

but there is nothing in the resulting page,
have you an idea of other solution ???

Thanks in any case

"Ivo" <no@thank.you> wrote in message news:<40***********************@news.wanadoo.nl>.. .
"Antonio" wrote
Good Morning,
I would want to insert the javascript of google adsense in my site,
here it is :

<script type="text/javascript"><!--
google_ad_client = "pub-4902392511135327";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

the problem is that I want to insert it inside a javascript file I
already use in a way that I've not to insert it in every page, how


var x=document.createElement('script');
x.src="http://pagead";

I think you can only create elements after the initial onload event has
fired (and only on newer browsers), so put it in a function.
To include the file even the before load, make an empty script tag the first
in each document and set document.srcipts[0].src explicitly in your own .js
file (IE only I think).
HTH
Ivo

Jul 23 '05 #3
Ivo
"Antonio" wrote
I made this :

function InserisciFooter()
{
document.write('<img src="' + base + 'images/barraFooter.png"
width="750" align="center">');

google_ad_client = "pub-4902392511135327";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
google_ad_type = "text_image";
google_color_border = ["B4D0DC","A8DDA0","578A24"];
google_color_bg = ["ECF8FF","EBFFED","CCFF99"];
google_color_link = ["0000CC","0000CC","00008B"];
google_color_url = ["008000","008000","00008B"];
google_color_text = ["6F6F6F","6F6F6F","000000"];
var x=document.createElement('script');
x.src="http://pagead2.googlesyndication.com/pagead/show_ads.js";
// Add this line here:
document.body.appendChild(x);
};

but there is nothing in the resulting page,
have you an idea of other solution ???


See little but essential missing required step above. Sorry. You could also
try with a local (to your website or even your own computer) file first to
rule out any loading errors.
HTH
Ivo
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Lucian Sandor | last post: by
5 posts views Thread by joaopedrogoncalves | last post: by
8 posts views Thread by Peter Michaux | last post: by
22 posts views Thread by Christopher Nelson | last post: by
pbmods
1 post views Thread by pbmods | last post: by
4 posts views Thread by =?Utf-8?B?R1ROMTcwNzc3?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.