• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 3.x Series
    • Bug
    • Tab browsing stops execution on java event

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: Tab browsing stops execution on java event

    • Issue Tools
      • View Changes
    1. issueid=1668 June 10, 2010 10:23 PM
      lordsilence lordsilence is offline
      Junior Member
      Tab browsing stops execution on java event

      If a tab such as "discussion" is hit on an article, if anywhere on the discussion tab has a javascript with an event that refreshes layout/texts before page loads the execution stops and only loads a blank page.

      This is mitigated by delaying the java onload event to allow the discussion tab to fully load. But the tab "nice" loading should be rewritten to allow for in-between execution, or not fail to render.

      It works fine to load the discussion link manually by copy / pasting the link.
      It's only if it renders on same page that this bug is evident.

      Example:
      Code:
      <div class="smallfont"><script type="text/javascript">(function(){var UNvar=document.getElementsByTagName('strong')[1].innerHTML;document.write(UNvar.substr(9,UNvar.length-10));})()</script> <-- someones username in vbulletin.</div>
    Issue Details
    Issue Number 1668
    Issue Type Bug
    Project VaultWiki 3.x Series
    Category Wiki Pages
    Status Fixed
    Priority 2 - Fatal / Database Errors
    Affected Version 2.0.0 Beta 3
    Fixed Version 3.0.1
    Milestone VaultWiki 3.0.5
    Software DependencyAny
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 0
    Assigned Users (none)
    Tags (none)




    1. June 10, 2010 10:58 PM
      pegasus pegasus is offline
      VaultWiki Team
      Actually this is a known issue with document.write() and was a point in one of my rants several years back about why Javascript coders should be avoiding it at all costs. You can always replace a document.write with an object-oriented approach. I have no idea what you're trying to accomplish by selecting the second strong tag on the whole page, but instead of using document.write, you should be able to use:
      Code:
      this.parentNode.innerHTML = whatever is in parentheses
      Basically because the ajax.response doesn't have a document object, it creates one and fills it with whatever was supposed to be written. This results in the tab becoming erased, and subsequently the page, because there ends up being 2 DOMs...
      Reply Reply  
    2. June 10, 2010 11:40 PM
      lordsilence lordsilence is offline
      Junior Member
      Thanks

      Do you mean something like this below?

      Code:
      <script type="text/javascript">(function(){var
      UNvar=document.getElementsByTagName('strong')[1].innerHTML;this.parentNode.innerHTML(UNvar.substr(9,UNvar.len gth-10));})()</script>
      Reply Reply  
    3. June 10, 2010 11:59 PM
      pegasus pegasus is offline
      VaultWiki Team
      As I mentioned, I'm not exactly sure what you're trying to accomplish, so it may need to be a little different, but that's the general idea IIRC.
      Reply Reply  
    4. June 11, 2010 12:33 AM
      lordsilence lordsilence is offline
      Junior Member
      Sorry about all the weird questions.
      This javascript is a part of our auditing package of our forum.

      The forum is setup with some heavy customized stuff to provide a security platform and auditing of all access.

      That part of javascript will only output the name of a user browsing a thread in clear text.
      Nothing else
      Reply Reply  
    5. June 20, 2010 11:22 PM
      pegasus pegasus is offline
      VaultWiki Team
      There is no way to parse document.write() after the page has finished loading (https://developer.mozilla.org/en/DOM/document.write). Its behavior re-runs document.open() in that case, which resets the existing document object.

      In order to fix this, I needed to do quite a bit of thinking outside the box. Here's the code snippet that I came up with. Since we are eval()ing script tags individually, we have the DOM reference of the script itself (from an earlier getElementsByTagName("script")) and stored it in window.resetObj. This allows the magic to begin - we replace document.write() with a new function that does the same job, except it uses object references rather than directly writing to the page:
      Code:
      // store the original document.write for later
      var docWriteOrig = document.write;
      
      // redefine document.write
      document.write = function(src)
      {
      	// make sure we have a reference to the containing script tag
      	if (window.resetObj)
      	{
      		// create a temporary HTML object (in memory, not rendered)
      		var dummy = document.createElement("div");
      
      		// in order for the document.write data to NOT be treated as plain text,
      		// add it as the HTML of an existing node
      		dummy.innerHTML = src;
      
      		// make sure the temporary container now has data
      		if (dummy.hasChildNodes())
      		{
      			// the data was converted to nodes, so cycle through them
      			for (var cn = 0; cn < dummy.childNodes.length; cn++)
      			{
      				// place each node in order before the script tag
      				YAHOO.util.Dom.insertBefore(dummy.childNodes[cn], window.resetObj);
      			}
      		}
      	}
      	else
      	{
      		docWriteOrig(src);
      	}
      };
      This fix is included in the next build. To give some perspective, this issue first appeared in 2.0.0 Beta 3, which was released on June 22, 2008.

      If anyone wants to reuse this code, probably an easier way to get the script node reference (what's needed to use the object method) is to do something like the following on your page:
      HTML Code:
      <script type="text/javascript" id="script_instance_1">
      <!--
      window.resetObj = document.getElementById("script_instance_1");
      document.write('your text');
      window.resetObj = null;
      //-->
      </script>
      As far as I can tell, there is no way to completely automate it reliably. You need to set the object each time or the original document.write will be called.
      Reply Reply  
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 12:45 PM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2023 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2023 DragonByte Technologies Ltd.
    Copyright © 2008 - 2013 VaultWiki Team, Cracked Egg Studios, LLC.