When I write in the URL bar

javscript:document.getElementById("existing_elementid").innerHTML = "some text";

my browser doesn't change the innerHTML of the object but removes the whole page and set "some text" instead.

After that the source code looks like this:

<html>
 <head></head>
 <body>
  some text
 </body>
</html>

Edit:

  1. Before it forwards to this empty site, I can see that the command was normal executed (the content of existing_elementid was changed to "some text").
  2. When I tried to do the same on the console, the result was the desired one. But the console also gave me the answer "some text". Maybe the problem is that bookmarklet gives it answers as new pages?
有帮助吗?

解决方案

whoa, i hope there's a better solution to this, but.. this seems to work.. (right on this stackoverflow page, in fact)

javascript:document.querySelector("#nav-questions").innerHTML="test";window.stop();

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top