What is the best practice for writing bookmarklets
Posted
by Ritesh M Nayak
on Stack Overflow
See other posts from Stack Overflow
or by Ritesh M Nayak
Published on 2009-12-19T13:23:05Z
Indexed on
2010/03/26
17:13 UTC
Read the original article
Hit count: 397
I am writing some bookmarklets for a project that I am currently working on and I was wondering what the best practice for writing a bookmarklet was. I did some looking around and this is what I came up with
javascript:void((function()
{
var%20e=document.createElement('script');
e.setAttribute('type','text/javascript');
e.setAttribute('src','http://someserver.com/bookmarkletcode.js');
document.body.appendChild(e)
})())
I felt this is nice because the code can always be changed (since its requested every time) and still it acts like a bookmarklet. Are there are any problems to this approach ? Browser incompatibility etc? What is the best practice for this?
© Stack Overflow or respective owner