Javascript of Google inside my javascript file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antonio

    #1

    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_clien t = "pub-490239251113532 7";
    google_ad_width = 728;
    google_ad_heigh t = 90;
    google_ad_forma t = "728x90_as" ;
    google_ad_chann el ="";
    //--></script>
    <script type="text/javascript"
    src="http://pagead2.googles yndication.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.googles yndication.com/pagead/show_ads.js">
    </script>

    when I am inside another javascript file ???

    Thanks

    Ing. Antonio D'Ottavio
  • Ivo

    #2
    Re: Javascript of Google inside my javascript file

    "Antonio" wrote[color=blue]
    > Good Morning,
    > I would want to insert the javascript of google adsense in my site,
    > here it is :
    >
    > <script type="text/javascript"><!--
    > google_ad_clien t = "pub-490239251113532 7";
    > google_ad_width = 728;
    > google_ad_heigh t = 90;
    > google_ad_forma t = "728x90_as" ;
    > google_ad_chann el ="";
    > //--></script>
    > <script type="text/javascript"
    > src="http://pagead2.googles yndication.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[/color]

    var x=document.crea teElement('scri pt');
    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.srcipt s[0].src explicitly in your own .js
    file (IE only I think).
    HTH
    Ivo


    Comment

    • Antonio

      #3
      Re: Javascript of Google inside my javascript file

      I made this :

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

      google_ad_clien t = "pub-490239251113532 7";
      google_ad_width = 728;
      google_ad_heigh t = 90;
      google_ad_forma t = "728x90_as" ;
      google_ad_chann el ="";
      google_ad_type = "text_image ";
      google_color_bo rder = ["B4D0DC","A8DDA 0","578A24"];
      google_color_bg = ["ECF8FF","EBFFE D","CCFF99"];
      google_color_li nk = ["0000CC","0000C C","00008B"];
      google_color_ur l = ["008000","00800 0","00008B"];
      google_color_te xt = ["6F6F6F","6F6F6 F","000000"];
      var x=document.crea teElement('scri pt');
      x.src="http://pagead2.googles yndication.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:<40adad88$ 0$72192$abc4f4c 3@news.wanadoo. nl>...[color=blue]
      > "Antonio" wrote[color=green]
      > > Good Morning,
      > > I would want to insert the javascript of google adsense in my site,
      > > here it is :
      > >
      > > <script type="text/javascript"><!--
      > > google_ad_clien t = "pub-490239251113532 7";
      > > google_ad_width = 728;
      > > google_ad_heigh t = 90;
      > > google_ad_forma t = "728x90_as" ;
      > > google_ad_chann el ="";
      > > //--></script>
      > > <script type="text/javascript"
      > > src="http://pagead2.googles yndication.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[/color]
      >
      > var x=document.crea teElement('scri pt');
      > 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.srcipt s[0].src explicitly in your own .js
      > file (IE only I think).
      > HTH
      > Ivo[/color]

      Comment

      • Ivo

        #4
        Re: Javascript of Google inside my javascript file

        "Antonio" wrote[color=blue]
        > I made this :
        >
        > function InserisciFooter ()
        > {
        > document.write( '<img src="' + base + 'images/barraFooter.png "
        > width="750" align="center"> ');
        >
        > google_ad_clien t = "pub-490239251113532 7";
        > google_ad_width = 728;
        > google_ad_heigh t = 90;
        > google_ad_forma t = "728x90_as" ;
        > google_ad_chann el ="";
        > google_ad_type = "text_image ";
        > google_color_bo rder = ["B4D0DC","A8DDA 0","578A24"];
        > google_color_bg = ["ECF8FF","EBFFE D","CCFF99"];
        > google_color_li nk = ["0000CC","0000C C","00008B"];
        > google_color_ur l = ["008000","00800 0","00008B"];
        > google_color_te xt = ["6F6F6F","6F6F6 F","000000"];
        > var x=document.crea teElement('scri pt');
        > x.src="http://pagead2.googles yndication.com/pagead/show_ads.js";[/color]

        // Add this line here:
        document.body.a ppendChild(x);
        [color=blue]
        > };
        >
        > but there is nothing in the resulting page,
        > have you an idea of other solution ???[/color]

        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


        Comment

        Working...