Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • 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:

    Code:
    <script type="text/javascript">
    (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);
    })(); </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!

    Comment


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


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

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud customization and demonstration site.
        vBulletin 5 Documentation - Updated every Friday. Report issues here.
        vBulletin 5 API - Full / Mobile
        I am not currently available for vB Messenger Chats.

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