Created
August 6, 2012 23:47
-
-
Save thecodedrift/3279693 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var createScriptNode = (function() { | |
| var testScr = document.createElement("script"), | |
| property = "innerHTML"; | |
| testScr.type = "text/javascript"; | |
| try { | |
| testScr.text = ";"; | |
| property = "text"; | |
| } | |
| catch(e) {} | |
| return function(code) { | |
| var scr = document.createElement("script"); | |
| scr.type = "text/javascript"; | |
| scr[property] = code; | |
| return scr; | |
| } | |
| })(); | |
| var evalJSON = function(jsonString) { | |
| var exec = ["window.results =", jsonString], | |
| node = createScriptNode(exec), | |
| results; | |
| document.body.appendChild(node); | |
| results = window.results; | |
| delete window["results"]; | |
| return results; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createScriptNode(code) { | |
| var scr = document.createElement("script"); | |
| scr.type = "text/javascript"; | |
| scr.innerHTML = code; | |
| return scr; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createScriptNode(code) { | |
| var scr = document.createElement("script"); | |
| scr.type = "text/javascript"; | |
| try { | |
| scr.text = code; | |
| } | |
| catch(e) { | |
| try { | |
| scr.innerHTML = code; | |
| } | |
| catch(ee) { | |
| return false; | |
| } | |
| } | |
| return scr; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment