Muffinresearch Labs by Stuart Colville

Getting relative form actions with javascript | Comments (1)

Posted in Browsers, Code on 24th October 2006, 11:10 pm by Stuart

The other day I needed to get data from a form and manipulate the “get” manually through javascript. For that to happen I needed to obtain the action attribute of the form. The action of this specific form had to be a relative url. What I found through testing was that whether I used getAttribute('action') or action the relative url would sometimes become a fully qualified url depending on which method you used in which browser.

Method IE6 IE7 Firefox Opera Safari
getAttribute(’action’) Relative Relative Relative Fully Qualified Relative
action Relative Relative Fully Qualified Fully Qualified Relative

The end result of this little oddity is that you are best using fully qualified urls in form actions. However if you do need to use a relative url as an action you need to be careful to make sure that you end up with what you are expecting. For example I’d use getAttribute(’action’) and just fix the result coming from opera by checking for the presence of ‘http’.

See the simple example

Post Tools

Comments: Add yours

1. On November 1st, 2006 at 3:30 pm Isofarro said:

Good to know the relative URL on form action reacts the same way as the href attribute on links. I think this has to do with the difference between a node property (form.action), and a node attribute(form.getAttribute(’action’)).

Its handy way of dealing with relative URLs.







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Ubuntu: Turn off changing workspace with mouse wheel|(0)

I found the changing with the workspace with the mouse wheel really annoying. To disable it go to System => Preferences => CompizConfig (available if the compizconfig-settings-manager package is installed) and uncheck “Viewport Switcher” which is under the “Desktop” heading.

Ubuntu: Mounting a TrueCrypt volume at startup or from the CLI|(0)

All you need is a mount point e.g: mkdir /media/ and then use the following: truecrypt /path/to/truecrypt/diskimage /media/. This is handy when you want to mount a truecrypt image at start-up or just do it quickly from a shell. It’s far more direct than using the GUI.

Photos on Flickr

© Copyright 2004-09 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.828s.