Bug Tracker

Opened 10 years ago

Closed 10 years ago

#5406 closed bug (invalid)

selector + variable name cannot be the same in IE

Reported by: IGonza Owned by: john
Priority: major Milestone: 1.3.2
Component: selector Version: 1.3.2
Keywords: selector Cc:
Blocked by: Blocking:

Description

function testbug() {

test_field = $("#test_field");

}

<input type="text" value="1" id="test_field"><a href="javascript:void(0)" onClick="javascript:testbug();">Click me</a>

That function returns an error in IE 7. But works in FF, Safari, Chrome.

Row : test_field = $("#test_field"); returns an error; Row : var test_field = $("#test_field"); works fine.

Is it a bug?

Change History (2)

comment:1 Changed 10 years ago by pbcomm

try this: function testbug() {

var test_field = $("#test_field");

}

<input type="text" value="1" id="test_field"><a href="javascript:void(0)" onclick="testbug()">Click me</a>

comment:2 Changed 10 years ago by dmethvin

Resolution: invalid
Status: newclosed

IE puts names and ids into the global namespace. jQuery can't really work around that. So, do not give any elements a name or id that is the same as a variable in your Javascript code.

http://www.phpied.com/browser-implied-globals/

http://yura.thinkweb2.com/domlint/

Note: See TracTickets for help on using tickets.