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>



Using Loggerhead with mod_wsgi|(0)

Here’s a post I wrote over on the Project Fondue Blog about our use of Loggerhead with mod_wsgi under Apache. Loggerhead is the rather nice branch viewer for bazaar branches as used on Launchpad.net.

If you’re not already subscribed to the Project Fondue blog feed then I can recommend it, as there should be some interesting posts coming out of there in the coming months (yes I’m unashamedly biased!).

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

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.

Photos on Flickr

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