Javascript of Google inside my javascript file

A

Antonio

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
 
I

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
 
A

Antonio

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 said:
"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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top