Jump to:

23491 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » position on javascript within the <body>

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 808 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    position on javascript within the <body> Link to this post

    Hi,

    I have a site which includes google adverts. To place the adverts on the page, you have to put javascript within the body, on the page where you want it.

    However, silverstripe then dumps all the javascript stuff directly after this google adsense script. This is causing a problem with the facebook connect module in IE6 becuase it tries to reload the page while the containing element isn't loaded and closed off.

    How would I put some javascript on the page, and keep the rest right at the end of document...

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: position on javascript within the <body> Link to this post

    If you put the script on the page using a plain <script ...> tag instead of the SS <% require %> then SS will not move you script.

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: position on javascript within the <body> Link to this post

    that's what I have:

    the javascript is:

    <script type="text/javascript"><!--
    google_ad_client = "123123123123123";
    google_ad_slot = "12312312313123";
    google_ad_width = 728;
    google_ad_height = 90;
    //-->
    </script>
    <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>

    this is in my template. SS is then dumping all the other javacript files linked in using <% require javascript() %> just after my google adsense code. If I remove the google adsense the other javacscript stuff goes back to being at the bottom of the html....

  • Futureweb
    Avatar
    Community Member
    232 Posts
  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: position on javascript within the <body> Link to this post

    Yes this is how Requirements is designed to work.

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: position on javascript within the <body> Link to this post

    hmm, that seems a wee bit odd to me! So, if i want to have some script on the page - and also some right at the end of the html, I can't use <% require %> ??

    The problem is actually with the facebookConnect module - this adds custom javascript which HAS to be at the very end of the html - otherwise it causes massive problems in IE6 - (eg, it just fails to load anything on the page and i get a white blank page and error message)

    I've got it working just now by taking the javascript out of the facebook connect module, and writing it directly into the bottom of my main page.ss template file...

    808 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.