[code] Cleanup After execute_script
-
This code cleans-up the cruft left behind when using execute_script. (reference thread)
Chris' version: (http://forums.sketchucation.com/viewtopic.php?p=274499#p274499)
function corePurge(){ coll = document.body.childNodes; for(a=0; a < coll.length; a += 1){ if (coll[a].tagName === "SCRIPT" && coll[a].id === ""){ document.body.removeChild(coll[a]); a -= 1; } } }My version:
function purge_script_tags() { var b = document.body; var last_node = b.lastChild; while(last_node.nodeName === "SCRIPT") { b.removeChild(last_node); last_node = b.lastChild; } } -
jQuery version:
$('body script').detach(); -
@jim said:
...
My version:
function purge_script_tags() { > var b = document.body; > var last_node = b.lastChild; > while(last_node.nodeName === "SCRIPT") { > b.removeChild(last_node); > last_node = b.lastChild; > } > }This would remove all last scripts including ones not by
execute_script- UHMS -
And in Chris' edition.. if a developer wanted to avoid being cleaned up, he need only set an id attribute on the script object.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement