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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StephenKay
    Senior Member
    • Apr 2003
    • 437

    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:

    Code:
    <script type="text/javascript">[INDENT](function() {
    var trial = document.createElement('script');
    trial.type = 'text/javascript';
    trial.async = true;
    trial.src = 'https://easy.myfonts.net/v2/js?sid=270461(font-family=Pinot+Grigio+Modern+Bold)&sid=270462(font-family=Pinot+Grigio+Modern+Light)&sid=270463(font-family=Pinot+Grigio+Modern+Medium)&key=KEYCODEREMOVED';
    var head = document.getElementsByTagName("head")[0];
    head.appendChild(trial);[/INDENT]
     })();
    </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?
  • glennrocksvb
    Former vBulletin Developer
    • Mar 2011
    • 4020
    • 5.7.X

    #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?

    Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

    Comment

    • StephenKay
      Senior Member
      • Apr 2003
      • 437

      #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.

      Comment

      • Wayne Luke
        vBulletin Technical Support Lead
        • Aug 2000
        • 74078

        #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, 3:10pm.
        Translations provided by Google.

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

        Comment


        • 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.
      Working...