Cookie editor bookmarklet

  • Thread starter Jesper Rønn-Jensen
  • Start date
J

Jesper Rønn-Jensen

Hi everybody.
I just created a bookmarklet that can view, add and edit cookies.
Feel free to use it, if you like. And please share any modifications
you make.

I had a hard time figuring out exactly which characters are allowed.
For instance, i _think_ the equal sign (=) is allowed even though it
has special meaning in the cookie string.

The bookmarklet creates a popup window and loads a javascript file from
my webserver.

I really appreciate any comments/feedback/suggestions.
For now, I have tried it in Firefox 1.0.1 and IE6 /windows

javascript:(function(){u='http://visitjesper.homeip.net/cookieeditor.js';w=window.open();w.document.write('<html><head></head><body></body></html>');w.document.close();s=w.document.body.appendChild(w.document.createElement('script'));s.type='text/javascript';s.src=u;})()


Kind regards,
Jesper
 
I

Ivo

javascript:(function(){u='http://visitjesper.homeip.net/cookieeditor.js';w=w
indow.open();w.document.write('<html><head></head><body></body></html>');w.d
ocument.close();s=w.document.body.appendChild(w.document.createElement('scri
pt'));s.type='text/javascript';s.src=u;})()

Well, encapsulating your statements in a function is rather nice but also
quite pointless if you don't initialize the variables using the "var"
keyword. Because now they still end up being global variables which is never
a good idea and certainly not in bookmarklet that need to adept to any and
all pages that may well have their own global variables that you don't want
to interfere with.
The url to your .js file is in a variable "u" that you use only once, why
not assign it directly to "s.src"? And why mix document.write() and
document.createElement()? Also, when writing HTML with javascript, the
closing tags should look like this:

<\/tag>

with a backslash escaping the slash. It may not break the script in all
cases if you don't, but it never hurts so it 's best to get used to it. A
parser might think the script section has ended when it encounters the
string "</" without backslash, ending your script prematurely.
 
J

Jesper Rønn-Jensen

Thanks for your response. Good points about declaring my variables with
'var'.


Jesper
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top