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>



Scrolling issue in Leopard cured with PRAM reset|(0)

Having got a shiny new MacBook Pro to work on at my new workplace I’ve had a couple of strange problems with Leopard. The main issue was that when scrolling the graphics was suffering what appeared to be a strange redraw problem when scrolling. After googling I found this post:“Distorted graphics in Leopard when scrolling”.

Fortunately for me: resetting the PRAM has worked and the flickering issue has gone for now.

Using git with Django’s SVN repository|(0)

Brian Rosner has produced a really nice screencast demonstrating ways to use git version control with Django’s SVN repository. Especially of interest is how merging changes you’ve made in your git branch of Django with updates from the Django SVN repository is really straightforward.

Photos on Flickr

© Copyright 2004-08 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosted by WebMax Nefarious Muffins. This page was baked in 0.706s.