The Javascript Shell is an awesome utility for javascript development. It was written by Jesse Ruderman and some other contributors.
The bookmarklet version is the most useful, but it unfortunately only works in Firefox.
Here is an updated version which brings some love to IE developers: Javascript Shell for IE bookmarklet.
You might run into issues with pop-up blockers, in which case you can simply allow pop-ups from the site you're working with.
Here is the fixed getcaretpos method, which uses a technique described by Mihai Bazon:
// IE specific code
var range = document.selection.createRange();
var isCollapsed = range.compareEndPoints("StartToEnd", range) == 0;
if (!isCollapsed)
range.collapse(false);
var b = range.getBookmark();
return b.charCodeAt(2) - 2;
}
If you evaluate "document.getElementsByName" in IE, you get:
"function getElementsByName() { [native code] }".
So it looks like native methods don't get listed when enumerating the members of an object. A more direct repro is to call "props(document)" or evaluate "for(var i in document) { print(i); }".
Within the Javascript Shell on Firefox this will list "getElementsByName" as one of the possibilities, but it's missing in the case of IE.
Any suggestions on how to work around this?
Update (2006/04/26): I posted a screencast of the Javascript Shell bookmarklet for IE on PutFile (best viewed in "800" size).
Update (2006/05/01): Joshua Allen, who is now a technical evangelist on the IE7 team, pointed out that this bookmarklet doesn't work in the latest version of IE7.
IE7 Beta 2 (5346.5) crashes when you try to launch the javascript shell from the bookmarklet. I'll follow up with him to investigate.
Update (2006/06/07): I haven't identified the crashing issue yet, it didn't crash for me on all the versions of IE7 that I tried.
I did a fix for IE7 though: you can now complete with Ctrl-Space, in addition to Tab. Tab doesn't work well, because it actually moves the focus to the new url bar in pop-up windows... Use Ctrl-Space instead.
Nice job - this is badly needed in IE.
Posted by: Patrick Fitzgerald at April 28, 2006 02:38 PMThis script causes IE7 to crash?
This is badly needed for IE, it has been a great
tool in Firefox and I hope to use it in IE.
Posted by: Oliver at May 16, 2006 04:40 PM
What's about Opera?
Posted by: Antonio at June 25, 2006 01:47 PM