I'm trying to become better in the art of making bookmarklets. They're so fascinating! However, the code that works perfectly in the console doesn't work as bookmarklet, as, after the execution, the page is redirected to the url of the code.; is there a reason?
Code:
<a href='javascript:try{document.getElementsByTagName("title")[0].innerHTML=prompt("new title")||"empty"}catch(e){}'>Change Title</a>
JavaScript:
try {
document.getElementsByTagName("title")[0].innerHTML = prompt("new title")||"empty" // in the event that there is no user input
} catch(e) {} // in the event that no title is found