We use some mini-scripts often, so we add them as buttons in the IE link toolbar. We test them by typing the prefix "javascript:" and the script itself into the address window of the browser. If the script has several steps, we encapsulate it into a function, and follow the "javascript:" with a "function()" definition.
Hit the 'Try it:' buttons, or test them in your browser.
The scripts include commands to:
1. Display the current site's cookie, if it has one.
2. Reveal the generated source code of the current page.
3. Close nag sites without evoking popups.
4. Run a local file.
5. Zoom in on a page.
6. Zoom out of a page.
7. Restore a page to normal, after zooming around.
Creating Buttons in your IE toolbar.
IE 6 users may have to 'unlock' the toolbar first, but once done, copy and paste the text into your address bar. Hit <Enter> to start it.
Drag the icon from the address to your button bar to automatically create the button. Right click on your new button (you may have to select it from the drop-down Links menu), and select Properties to rename it something more reasonable.
1) Show Cookie Contents:
Click this button to display the contents of the cookie (if there is one) for the current page:
Try it:
|
javascript:alert("Cookie: "+ document.cookie)
|
|
|
|
|
2) Reveal Source Code:
This function displays the Generated Source Code, as interpreted by the browser. It bypasses many of the silly encryption schemes used on web pages, and shows what the browser really sees.
Try it:
|
javascript:(function(){ function htmlEscape(s){s=s.replace(/&/g,'&'); s=s.replace(/>/g,'>');s=s.replace(/</g,'<');return s;} x=window.open(); x.document.write('<pre>' + htmlEscape('<html>\n' + document.documentElement.innerHTML + '\n</html>')); x.document.close(); })();
|
|
|
|
|
3) Close Current Window and any child popups.
This function precludes popups from displaying while closing the current window.
Try it by pasting it into your address window, and hitting <Enter>.
|
javascript:window.onload=window.onunload=window.onbeforeunload=null; window.close(); |
|
|
|
|
4) Run a file:
Sometimes, it helps to run an executable from the same toolbar. Especially those web-page analyzers we like to run sometimes. This is an example; maybe it's just a text file:
Try it by running a file of your choosing on your workstation.
|
file:///c:/Documents%20and%20Settings/user/Desktop/tips/notes.txt
|
|
|
|
|
5) Zoom in on a Web Page:
With IE 5.5, you can zoom in and out of your web, help or ebook pages. Animations and links still work at any resolution, and it prints the same way it displays onscreen.
It is very cool. Adjust the degree of zoom to taste.
Try it:
|
javascript:(function(){ function zoomin(){if(window.parent.document.body.style.zoom!=0) window.parent.document.body.style.zoom*=1.2; else window.parent.document.body.style.zoom=1.2;}zoomin();})();
|
|
|
|
|
6) And of course, Zoom Out of a Web Page:
Zooming out is pretty much the same as zooming in, but the numbers are changed to go the other direction. It's obvious, but we needed to say something here...
Try it:
|
javascript:(function(){ function zoomout(){if(window.parent.document.body.style.zoom!=0) window.parent.document.body.style.zoom*=0.8; else window.parent.document.body.style.zoom=0.8;}zoomout();})();
|
|
|
|
|
7) To return to normal, you could always refresh the page, or use this:
Try it:
|
javascript:(function(){ function zoomrest(){if(window.parent.document.body.style.zoom!=0) window.parent.document.body.style.zoom*=0; else window.parent.document.body.style.zoom=0;}zoomrest();})();
|
|
|
|
|
So there you have it. The zoom functions are IE 5.5+ specific, so we are limited to using them in HtmlHelp, ebooks, company intranets and applications, and IE-only web pages.
If you have any favorite scripts, for IE buttons, help systems, navigation, or any other interesting functions, send them in, and we'll do our best to post them.