May 26, 2004

Curious George: Getting out of frames jail. How can I close a Web page frame using a "javascript:" command on a browser address: bar? Of course this assumes I can find the frame name. An example: the frame at the top of this page. On sites like Delphi Forum boards I am frequently stuck in "frames jail" where 20% of the screen is occupied by dead space. No luck Googling on this one -- far too many nonrelevant hits to sift through.
  • I use the right-click menu in mozilla to "This Frame -> Show Only This Frame"
  • pete's solution is in most browsers, but if you really want a "command line" solution: javascript:window.location = window.frames[0].location. This will set open the first frame in the frameset in the main window - the red frame in the example given. frames in the browser DOM index at 0, so the first frame is frames[0], the second frame is frames[1] and so on.
  • This is one of a countless number of reasons that I use FireFox. Sure, I can right-click and select Show only This Frame, but I also have the ability to resize the frame. Hover you mouse over the edge of the frame, click and drag to resize. You get all of the benefits (if any) of the frame, while being able to dictate the size. Or, what schadenfreude said.
  • I don't know javascript, but firefox does have the right click option built in and there are similar functions available for IE. Go to the Web Accessories for IE5 and download the Internet Explorer 5 Web Accessories, Power Tweaks Web Accessories, and Web Developer Accessories. They are for IE5 but they work fine on the latest version of IE. One of them has the right click, open frame in new window command, but I can't remember each and they are tiny and pretty usefull so download them all.
  • Thanks! These are great suggestions. Schaudenfreude's command worked right off the bat. I'll have to check out Firefox... I've always liked those old Clint Eastwood flicks. j/k
  • I am a bit of a freak when it comes to this sort of thing, so I put a little more effort into the script, for no other reason but to see if i could make it a little more usable. It lists the names and the numbers of the frames. You can type in either into the prompt. javascript:f='';for(x=0;x
  • Just for your own info schadenfreude, your script doesn't completely work in IE6. The prompt window that pops up doesn't resize itself to allow enough room to display the full frame list. You only get a basic 3 line prompt window which cuts off all frame choices after the first one.
  • Thanks Nal, IE on the Mac adds a scrollbar to the prompt, so I figured... easy to fix. Change: window.frames[x].name+'\n'; to: window.frames[x].name+' ';
  • rolypolyman - sorry 'bout your frames troubles; frames in general are a pain in the butt. and do try firefox, i've converted more than one IE user after a quick demo of what my browser can do that theirs can't. jccalhoun - thanks for reminding me about those IE extensions, sort of forgot they existed after i got a new computer. for similar (superior, in my book) functionality try the web developer toolbar for mozilla / firefox. DOM inspector, enable/disable page features at will, instant code validation, etc. - everything even the casual website author needs to have handy. if you have firefox it even adds live CSS editing to any page you are viewing - resulting CSS can be saved locally as a file.
  • Here is one that I use to get rid of the stupid blue frame in Hotmail w/ IE6: javascript:r=/hm___action=(.*)$/;m=r.exec(window.location);window.location=unescape(m[1]); Drag the above link to IE6's "Links" toolbar. Yes, it's safe. No, it won't take you anywhere. Now, whenever you get the frame that says, 'you are leaving hotmail... blah blah blah... close this window to return to hotmail...', just click on your new link button.