Skip to content

Instantly share code, notes, and snippets.

@devinrhode2
Created April 13, 2012 02:59
Show Gist options
  • Save devinrhode2/2373209 to your computer and use it in GitHub Desktop.
Save devinrhode2/2373209 to your computer and use it in GitHub Desktop.
String concatentation errors suck!
var script = document.createElement('script');
script.innerHTML =
'if (window.top !== window) { '+
' var subFrame = document.createElement("script"); '+
' subFrame.src = "'+chrome.extension.getURL('specific/sub_frame.js')+'";'+
' document.documentElement.appendChild(subFrame); '
'}';
document.documentElement.appendChild(script);
//gives "unexpected end of input", with no line numbers!
someStyleElement.innerHTML =
'html {display: none; /*trolling*/}' +
+'div {display: block !important; }'
+'foo{color: black;}';
//Silently gives: "html {display: none; /*trolling*/}NaNfoo{color: black;}" FARDGE!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment