No announcement yet.

Where to put a javascript script to be included on every page?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Where to put a javascript script to be included on every page?

    I want to test some web fonts on my site. The place selling the particular fonts has a way you can try them for thirty days. You include a script like this in the head of your html:

    <script type="text/javascript">
    (function() { var trial = document.createElement('script'); trial.type = 'text/javascript'; trial.async = true; trial.src = ''; var head = document.getElementsByTagName("head")[0]; head.appendChild(trial);
    })(); </script>
    I tried it in a default html page, and it works. Now I want to test it on vBulletin pages. I thought I could paste it into "head_include" in the Style Manager but that doesn't seem to work... is there some other place to put this so it gets included by default on every page?

  • #2
    Adding it in head_include template should work. What exactly happened when you did? Did you see any javascript error in the javascript console?

    GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!


    • #3
      Thanks for confirming that. I later found out that something is wrong with the site hosting the web fonts. I wasn't familiar with the javascript console (thanks), but now I've located it in FireFox and can indeed see an error related to the script not loading. But it's not a vBulletin thing.


      • #4
        You can find hundreds of free web fonts at Google Fonts. They are provided via CSS links.
        Last edited by Wayne Luke; Wed 22 Nov '17, 4:10pm.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API


        • StephenKay
          StephenKay commented
          Editing a comment
          Thanks, yes I've been experimenting with those!
      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.