Talk:Content Scope Runner: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
(Created page with 'What is it about this technique that stops execution of the remainder of the script?')
 
(This works)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
What is it about this technique that stops execution of the remainder of the script?
What is it about this technique that stops execution of the remainder of the script?
: Yeah, it fails to do that. I'm going to experiment a bit to see if I can fix that. -- [[User:Phyzome|Phyzome]] 05:31, 25 July 2010 (UTC)
Here, this actually works, but only when inlined in a script:
<pre class="sample">if(typeof __PAGE_SCOPE_RUN__ == 'undefined') {
  (function page_scope_runner() {
      var script = document.createElement('script');
      script.setAttribute("type", "application/javascript");
      script.textContent = "(function() { var __PAGE_SCOPE_RUN__ = 'yes'; (" + page_scope_runner.caller.toString() + ")(); })();";
      document.documentElement.appendChild(script);
      document.documentElement.removeChild(script);
  })();
  return;
}</pre>
-- [[User:Phyzome|Phyzome]] 06:34, 25 July 2010 (UTC)

Latest revision as of 06:34, 25 July 2010

What is it about this technique that stops execution of the remainder of the script?

Yeah, it fails to do that. I'm going to experiment a bit to see if I can fix that. -- Phyzome 05:31, 25 July 2010 (UTC)

Here, this actually works, but only when inlined in a script:

if(typeof __PAGE_SCOPE_RUN__ == 'undefined') {
   (function page_scope_runner() {
      var script = document.createElement('script');
      script.setAttribute("type", "application/javascript");
      script.textContent = "(function() { var __PAGE_SCOPE_RUN__ = 'yes'; (" + page_scope_runner.caller.toString() + ")(); })();";
      document.documentElement.appendChild(script);
      document.documentElement.removeChild(script);
   })();
   return;
}

-- Phyzome 06:34, 25 July 2010 (UTC)