This is my current bookmarklet:
javascript:(function(){ alert(location.href); })();
which seems to work fine, but for me, it doesn’t work on youtube under chrome for some reason.. is there a more robust way to get the location.href? Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. You may try
which will make sure you’re not using some custom
alertfunction from the global namespace. But, there is no way preventwindow.alertfrom being overwritten like sowindow.alert = function () { console.log('Haha!'); };.The
locationobject should be fail-proof, since the browser’s internal setter method inhibits any shenanigans there (meaning thatwindow‘slocationattribute is effectively write-protected, as iswindow.location‘shrefattribute)Edit:
Looks like bookmarklets don’t work in Firefox 6+ due to “social engineering bookmarklet attacks”, and there’s nothing you can do about it.
https://stackoverflow.com/a/6643466/27862
https://bugzilla.mozilla.org/show_bug.cgi?id=527530