-1
document.getElementById('channel_actions').innerHTML =     document.getElementById('channel_actions').innerHTML + '<button id = "toggleButton" style =     "position: absolute;height:32px;margin-left:0px" onclick = "toggleOverlay();">Start Overlay</button>';

How come when I do this in my chrome console it adds on to the page like expected but when I make it a bookmarklet this is the only thing it shows. It almost seems like the bookmarklet is calling document.write(My code) or something. Any help is appreciated.

3 Answers3

0

Are you prefacing the bookmarklet with javascript:?

elixenide
  • 44,308
  • 16
  • 74
  • 100
0

The old way: javascript:/*your code*/; void(0);

Best practice: javacript:(function(){ /*your code*/ })();

DG.
  • 3,417
  • 2
  • 23
  • 28
  • Yes I am using the best practice way. But why is it giving me different results when i use a proper bookmarklet vrs inputing it directly into google chrome? – user2939924 Oct 31 '13 at 18:42
  • Then you need to be more clear next time and show that. You waste people's time. – DG. Oct 31 '13 at 23:43
0

I've figured it out. for some reason i need to make a function start and instead of making the button pop up i use set timeout(start,100) and it worked.