Welcome to WebmasterWorld Guest from 54.226.194.180

Forum Moderators: open

Message Too Old, No Replies

What's the equivalent of 'setAttribute' for IE6?

I think I have it but need help with the command format.

     

snowweb

7:12 am on Oct 17, 2007 (gmt 0)

5+ Year Member



Hi,

The following works perfectly in ff:


elem.setAttribute("onBlur","updateField('t_',this.value,'"+recordId+"','"+escape(data_nohead)+"')");

But I need to accomodate IE6 & 7. The following works in IE7 but in IE6 is doesn't include the 4th parameter 'escape(data_nohead)':


elem.onBlur = function elem(){ updateField('t_',this.value,recordId,escape(data_nohead));};

'data_nohead', is a string variable.

Can someone help me please?

Thanks

daveVk

7:30 am on Oct 17, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



'data_nohead' needs to be a global variable (as does recordId)

elem.onBlur = function elem(){ updateField('t_',this.value,recordId,escape(data_nohead));};

function does not need to be named, leave red bit out, naming it the same as variable elem not a great idea?

snowweb

8:01 am on Oct 17, 2007 (gmt 0)

5+ Year Member



Thanks Dave. I've corrected the function declaration by removing the name as you suggested. It now looks like this:


elem.onBlur = function(){ updateField('t_',this.value,recordId,escape(data_nohead));};

Regarding the two variables, 'data_nohead' and 'recordId', I just got them alerted back to me immediately before where I used them above, and they were both present.

I'm trying to understand why they need to be globals? Once data_nohead has deposited it's contents as a string in the parameters list, I should have no further need for the variable.

What I'm wondering is whether I need to put that parameter (the last one), in quotes and if so, what type?

snowweb

10:07 am on Oct 17, 2007 (gmt 0)

5+ Year Member



I finally found the problem. I discovered that the event handlers are case sensitive and that they have to be in lower case to work in Internet Explorer!

Thanks for highlighting the problem with my naming of functions. :)

Regards, peter

daveVk

11:45 am on Oct 17, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



For the record. When the onblur occurs this is executed

updateField('t_',this.value,recordId,escape(data_nohead));

the variables need to exist at this time. This differs from the setAtribute case where the value of recordId is encoded into the function.

Dabrowski

2:03 pm on Oct 17, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Better to use addevent for event handlers, as this will prevent overwriting any other events.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month