Announcement

Collapse
No announcement yet.

vBulletin 5.3 - Where to insert jquery code?

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    vBulletin 5.3 - Where to insert jquery code?

    I am trying to add the following code into the footer of my templates and when I do so, it causes the links for replying to a post to disappear from my forum.

    The purpose of this code is to present a popup when a user scrolls down on the page.

    I am inserting it into the Footer for my active templates as shown here.

    Can you please tell me where I should be inserting this code so that it does not prevent the forum from working properly?

    1. I Place this code just above the closing body tag:

    <div id="scrollbox"></div>

    2. I Place this code below the closing html tag:

    <script src="https://code.jquery.com/jquery-2.2.3.js" integrity="sha256-laXWtGydpwqJ8JA+X9x2miwmaiKhn8tVmOVEigRNtP4="cross origin="anonymous"></script>
    <script type="text/javascript">
    var request_uri = '/' + window.location.pathname.substr(1);
    var src = 'http://www.heart-valve-surgery.com/valvereplacement/valvereplacement/scrollbox?request_uri='+request_uri;

    jQuery.ajax({
    url: src,
    dataType: 'script',
    async: true
    });

    </script>

    #2
    You don't have to include jQuery as vB5 already has it.

    What does that scrollbox script do? You may not actually need jQuery just to include the scrollbox script.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    Comment


      #3
      When a user scrolls down, it is a popup inviting them to click and participate in a study. Unfortunately I'm a bit of a newb and only had instructions I was provided. Should I give it a shot with only this above the closing body tag? <div id="scrollbox"></div>

      Comment


        #4
        It is recommended not to edit existing vB templates (unless absolutely necessary) as it may caused template merge conflicts every time you upgrade. You would have to resolve those conflicts or the page(s) using that template will stop working.

        What you want to do can be accomplished without editing templates. You can create a template hook in the footer_before_body_end hook location with this code in a new template:

        HTML Code:
        <div id="scrollbox"></div>
        <script type="text/javascript">
        (function() {
            var request_uri = '/' + window.location.pathname.substr(1),
                src = 'http://www.heart-valve-surgery.com/valvereplacement/valvereplacement/scrollbox?request_uri=' + encodeURIComponent(request_uri),
                script = document.createElement('script');
        
            script.type = 'text/javascript';
            script.async = true;
            script.src = src;
            document.querySelector('head').appendChild(script);
        })();
        </script>
        Helpful? Donate. Thanks!
        Buy me a coffeePayPal QR Code
        Fast VPS Host for vBulletin:
        A2 Hosting & IONOS

        Comment


          #5
          Thanks - I will look into that and see if I can determine where that is done... At least I have something to look at now.

          Comment

          Users Viewing This Page

          Collapse

          There is 1 user viewing this forum topic.

          • Guest Guest

          Latest Posts

          Collapse

          Working...
          X
          Searching...Please wait.
          An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

          Please push the back button and reload the previous window.'
          An unexpected error was returned: 'Your submission could not be processed because the token has expired.

          Please push the back button and reload the previous window.'
          An internal error has occurred and the module cannot be displayed.
          There are no results that meet this criteria.
          Search Result for "|||"