Results 1 to 11 of 11

How to remove VBSEO's "window.onload" script from the footer of FORUMHOME & FORUMDISPLAY?

This is a discussion on How to remove VBSEO's "window.onload" script from the footer of FORUMHOME & FORUMDISPLAY? within the General Discussion forums, part of the vBSEO SEO Plugin category; Code: <script type="text/javascript"> //<![CDATA[ window.orig_onload = window.onload; window.onload = function() { if (is_ie || is_moz) { var cpost=document.location.hash;if(cpost){ if(cobj = ...

  1. #1
    Senior Member
    Real Name
    Marvin Hlavac
    Join Date
    Oct 2007
    Posts
    254
    Liked
    15 times

    How to remove VBSEO's "window.onload" script from the footer of FORUMHOME & FORUMDISPLAY?

    Code:
    
    <script type="text/javascript"> //<![CDATA[  window.orig_onload = window.onload; window.onload = function() { if (is_ie || is_moz) { var cpost=document.location.hash;if(cpost){ if(cobj = fetch_object(cpost.substring(1,cpost.length)))cobj.scrollIntoView(true); }}  if(typeof window.orig_onload == "function") window.orig_onload(); }  //]]> </script>
    If I understand it correctly, the above script, which is inserted to the footer by VBSEO, is needed in threads, but not on the home page and in forums. Which PHP file I need to modify and how, to remove the script from FORUMHOME & FORUMDISPLAY?

    Any help with this will be very much appreciated.

  2. #2
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    This code is on line 149 of functions_vbseo_seo.php

    Code:
    function vbseo_insert_code_parse()
    {
    global $vbseo_inscode;
    if(isset($vbseo_inscode['onload']))
    {
    vbseo_insert_code('
    window.orig_onload = window.onload;
    window.onload = function() {
    '.$vbseo_inscode['onload'].'
    if(typeof window.orig_onload == "function") window.orig_onload();
    }', 'body_end_js');
    unset($vbseo_inscode['onload']);
    }
    if(is_array($vbseo_inscode))
    foreach($vbseo_inscode as $place=>$inscode)
    if(strstr($place, '_js'))
    {
    vbseo_insert_code('
    <script type="text/javascript">
    //<=!=[=C=D=A=T=A=[
    '.$inscode.'
    //]=]=>
    </script>', str_replace('_js', '', $place));
    unset($vbseo_inscode[$place]);
    }
    }
    I'm not sure if a THIS_SCRIPT conditional or similar exists in this scope to switch it out. I'll flag this for the developers to take a look at.

  3. #3
    Senior Member
    Real Name
    Marvin Hlavac
    Join Date
    Oct 2007
    Posts
    254
    Liked
    15 times
    Hi Brian,

    Thanks for the prompt reply.

    For some reason, even if I completely remove the above code you posted from functions_vbseo_seo.php, I still see the entire script in my footer. I even disabled caching, just in case that was interfering, but no luck. The only time I see the script disappear is when I disable VBSEO product.

  4. #4
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,741
    Liked
    168 times
    Hello,

    you can remove this code in functions_vbseo_hook.php file:
    PHP Code:
            case 'forumhome_complete':
            
                
    vbseo_insert_code(
                    
    "if (is_ie || is_moz) { var cpost=document.location.hash;if(cpost){ if(cobj = fetch_object(cpost.substring(1,cpost.length)))cobj.scrollIntoView(true); }}",
                    
    'onload'); 

  5. #5
    Senior Member
    Real Name
    Marvin Hlavac
    Join Date
    Oct 2007
    Posts
    254
    Liked
    15 times
    Hi Oleg,

    Thanks for your help.

    I did try that, but even that failed to remove the script from the footer.

    Actually, out of desperation, I eventually removed functions_vbseo_seo.php completely, and also functions_vbseo_hook.php. Now I actually removed all functions_vbseo_***.php files from that one directory, and the script is still there.

    As far as I can tell, I disabled all possible caching that could have any effect on this. :-)

  6. #6
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    Do you use xcache or anything similar?

  7. #7
    Senior Member
    Real Name
    Marvin Hlavac
    Join Date
    Oct 2007
    Posts
    254
    Liked
    15 times
    I use memcached, but during my tests I did disable it in VBSEO > GENERAL SETTINGS > CACHING OPTIONS > CACHE TYPE

    But as soon as I disable VBSEO in PRODUCTS > MANAGE PRODUCTS, the script disappears from the footer. That's so far the only way I've managed to remove the code from the footer, nothing else seems to have any effect. :(

  8. #8
    Senior Member
    Real Name
    Marvin Hlavac
    Join Date
    Oct 2007
    Posts
    254
    Liked
    15 times
    I'm still not sure why the editing, or the removal, of the php file(s) didn't achieve the goal, but I've managed to remove the script by simply going to:

    AdminCP > Plugins & Products > Plugin Manager > vBSEO Forumhome Complete

    and removing the check-mark there. Problem solved :-)

    Would you guys be so kind and tell me if it is safe, or what risk I would be taking, by disabling also vBSEO Showthread Complete? I was under the impression the script had something to do with making sure the page scrolled correctly to the linked posts in a thread. For example, the following link:

    Code:
    ...how-remove-vbseos-window-onload-script-footer-forumhome-forumdisplay-51579/#post320024
    But such links do seem to work even with vBSEO Showthread Complete disabled. If there's no harm in disabling it, I'd like to disable it.

  9. #9
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    The Js is used for pagination set in the CP. If you allow users to change their posts per page value, their post123 may be on page 3 when the board default has it on page 4, thus it is necessary to perform a redirect when others (running deault) post a link with a post ID and a user running custom clicks it.

    If you don't allow users to change their pagination options (use forum default is the only option) than the code is not necessary. If you do, it must be retained or any user using a custom pagination will not see the desired content at linked urls.

  10. #10
    Senior Member
    Real Name
    Marvin Hlavac
    Join Date
    Oct 2007
    Posts
    254
    Liked
    15 times
    Hi Brian,

    Thanks very much for the explanation. I have removed the script already, and disabled the option to use non-default number of posts-per-page.

    I think I should now still be a bit concerned that if users who were using custom settings have posted links to specific posts, those links will no longer point to the correct location. But I will leave it as is for now.

    Thanks again.

  11. #11
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    Yes, anything with the #postxxxx in the url as a bookmark is subject to not linking to the correct post if it was placed by someone using custom pagination.

Similar Threads

  1. window.onload javascriptleri
    By gorsan in forum Türkçe
    Replies: 1
    Last Post: 11-30-2009, 04:52 AM
  2. Replies: 3
    Last Post: 09-16-2009, 01:11 AM
  3. Replies: 2
    Last Post: 08-16-2008, 01:25 PM
  4. Replies: 5
    Last Post: 09-09-2006, 04:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •