Archive for the 'JavaScript' Category

If you are a Google user - meaning Gmail, Google Docs, Google Calendar, Google Reader, etc - then you should know that by default, once you log in your sessions are typically not encrypted between your browser and the Google servers.

For some more technical information on this, check out dmiessler’s post on the subject.

He mentions using bookmarks to make force your browser to use Google’s secure connections - however I’ve noticed that occasionally depending on how you arrive to your Google services that you will switch to an unencrypted session without warning.

For that reason, If you are using Firefox and greasemonkey, I highly recommend installing the “Google Secure Pro” userscript. It automatically switches you from using http:// to https:// to ensure your data is encrypted to Google’s servers. This will increase your security greatly from using the unencrypted connections, which is good if you transfer confidential data over e-mail - like most normal people do!

I recently had a problem where I was opening a browser window from an e-mail client. After taking a survey, I wanted a button to close this same window. In IE, it was fine to simply use window.close(); to close the window. However, Firefox, the evil genius that it is, will not let you do that because it believes you did not click to open this window in the first place. In order to trick it, you quick load a blank page then close it. The code:

<a href="javascript:window.open('','_parent','');window.close();">
Close this window</a>

So now, when you click the link, it closes the browser window. It works in both IE and Firefox 1.5 (and I believe others as well, but not personally tested). Finding that snippet of code saved me a lot of time! So I hope someone else finds it useful.

Update, May 1 2008:

This code only works on Firefox 1.5 and IE. In Firefox 2.0, Unless a website opened up a window - it can not close it. So, in my case I want to close the window after a user takes a survey, opened from an email window. Firefox 2.0 gives this error: Scripts may not close windows that were not opened by the script. I’m not sure what the right answer is here. They are doing it to prevent malicious scripts from closing windows. But even if they added an option to change that, most users wouldnt have it enabled by default.

So… where does that leave us? Please let me know if anyone knows of code that can close a window with Javascript in Firefox 2.x or 3.x.

Greasmoney + Duggmirror

Don’t you hate it when you try to visit a digg story and the site has been dugg? Use the greasemonkey firefox plugin and this duggmirror greasemoney script to add three links to each digg entry - the duggmirror archive, Coral NYU Mirror, and the Google Cache of the page, all with a nice graphical interface. It’s easy too:

  1. Install Firefox (you mean you haven’t already?)
  2. Install Greasemonkey plugin
  3. Restart Firefox
  4. Visit the duggmirror script’s page and click “install this script”. A little box will pop up at the top of the browser screen, asking you for permission to install it.

That’s it! When you visit digg - you will see the extra links next to the post title. It works in any OS that firefox support (I’ve personally tested on Windows XP, Vista, and Ubuntu).

  • Welcome to systemBash, a technology and system administration blog by David Drager. If you enjoy this sort of content, can can subscribe to the RSS using the link to the right.