Skip to main content

Bug Tracker

Side navigation

#160 closed bug (fixed)

Opened August 31, 2006 07:59AM UTC

Closed October 06, 2006 03:01PM UTC

Last modified October 14, 2008 10:31AM UTC

a fix for getAttribute('action') in forms

Reported by: Fil Owned by:
Priority: minor Milestone:
Component: core Version:
Keywords: Cc: fil@rezo.net
Blocked by: Blocking:
Description

Hello,

there is (apparently) a bug in MSIE if we use getAttribute('action') on a

form, because it will give us the action property of the form, instead of

the value of its "action" input.

Example :

<form action="url">

<input type="text" name="action" value="ok" />

</form>

this.getAttribute('action') should be "ok", not "url".

A fix for this is to use:

this.getAttributeNode('action').nodeValue

(that's Renato's solution to fix form.js at http://zone.spip.org/trac/spip-zone/changeset/4794

Another one is to use:

s = this.getAttribute('action');

if (typeof(s)!='string')

s = this.attributes.action.value;

One of these patches might apply to jquery.js and/or form.js

There is definitively a bug here, that doesn't let ajax calls access the

"action" input value of a form.

http://jquery.com/discuss/2006-August/010153/

http://jquery.com/discuss/2006-August/010155/

Attachments (0)
Change History (5)

Changed September 09, 2006 11:20PM UTC by joern comment:1

component: ajaxcore

Your description is very irritating, but nonetheless, the problem exists. I just added a test for this: ok( $('#form').attr('action') == "formaction", 'Check for action attribute' );

It works with FF but fails in IE6.

Changed September 16, 2006 04:41PM UTC by joern comment:2

Tricky one. I tried adding this to jQuery.attr:

if( elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
  return elem.getAttributeNode(name).nodeValue;
}

While that passes my test in IE6, Opera 9.01 fails.

Anyway: It makes more sense to add this to jQuery.attr and change form.js to use jQuery.attr.

Changed October 02, 2006 04:16PM UTC by joern comment:3

Fixed in SVN for IE, Opera still fails to get the correct attribute. Any hints to to solve this for Opera are appreciated.

Changed October 06, 2006 03:01PM UTC by joern comment:4

resolution: → fixed
status: newclosed

Opera did work fine, but the test was crap. Fixed.

Changed November 27, 2006 11:57PM UTC by anonymous comment:5

In the given example:

<form action="url"> <input type="text" name="action" value="ok" /> </form>

this.getAttribute('action') should be "ok", not "url".

That is completely wrong. getAttribute is always surposed to get the attribute of an element. form is an element, and action is an attribute of the form. this.getAttribute('method') should also return get/post and not the value of a <input name="method"/> element.

To get the value of an form element use the .val() on the corresponding element.