|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ie8 javascript "new function" behaviorby a control using an httphandler. What I've run into is a problem with javascript as an attribute value. The following line of code used to work e.setAttribute(attributes[i].nodeName, new Function(attributes[i].nodeValue)); where attributes[i].nodeName = "onclick" and attributes[i].nodeValue = "jsfunction('value'); return false;" ie8 in standards mode renders this as onclick="[object]" and this just throws a javascript error when the user clicks on it ie8 in compatibility mode renders this correctly as onclick="jsfunction('value'); return false;" This works correctly for the user. Can anyone point me in the right direction in javascript to 1) identify ie8 as the browser 2) modify the line of code in error to something that works? TIA, -- Doug Heeren Project Manager TMC Transportation (515) 256-2918 Doug Heeren wrote:
> The following line of code used to work You can simply do> e.setAttribute(attributes[i].nodeName, new Function(attributes[i].nodeValue)); > where attributes[i].nodeName = "onclick" and attributes[i].nodeValue = > "jsfunction('value'); return false;" > Can anyone point me in the right direction in javascript to > 1) identify ie8 as the browser > 2) modify the line of code in error to something that works? e[attributes[i].nodeName] = new Function(attributes[i].nodeValue); no need to try to identify IE 8. That woks perfectly. What is the difference between the two? On the surface
they appear to do the same. -- Show quoteHide quoteDoug Heeren Project Manager Annett Holdings, Inc. (515) 256-2918 "Martin Honnen" wrote: > Doug Heeren wrote: > > > The following line of code used to work > > e.setAttribute(attributes[i].nodeName, new Function(attributes[i].nodeValue)); > > where attributes[i].nodeName = "onclick" and attributes[i].nodeValue = > > "jsfunction('value'); return false;" > > > > Can anyone point me in the right direction in javascript to > > 1) identify ie8 as the browser > > 2) modify the line of code in error to something that works? > > You can simply do > e[attributes[i].nodeName] = new Function(attributes[i].nodeValue); > no need to try to identify IE 8. > > > -- > > Martin Honnen --- MVP XML > http://msmvps.com/blogs/martin_honnen/ > Doug Heeren wrote:
> That woks perfectly. What is the difference between the two? On the surface Do they? No,> they appear to do the same. e[e[attributes[i].nodeName] = ... sets a property. e.setAttribute([attributes[i].nodeName], ...) is supposed to set an attribute but is broken by design in IE before version 8. That makes sense. I appreciate this very much!
-- Show quoteHide quoteDoug Heeren Project Manager Annett Holdings, Inc. (515) 256-2918 "Martin Honnen" wrote: > Doug Heeren wrote: > > That woks perfectly. What is the difference between the two? On the surface > > they appear to do the same. > > Do they? No, > e[e[attributes[i].nodeName] = ... > sets a property. > e.setAttribute([attributes[i].nodeName], ...) > is supposed to set an attribute but is broken by design in IE before > version 8. > > > -- > > Martin Honnen --- MVP XML > http://msmvps.com/blogs/martin_honnen/ >
Other interesting topics
Is there a way to keep the StreamWriter open?
Visual Basic is Dead! Detailsview updading issue Basic question: returning @@IDENTITY from stored procedure... Movenext and ASP.net enum or static class Document markup language version question Skinning Question for checkboxes winform security: strange error, where as I expected a redirect Employee TimeSheet/Projects |
|||||||||||||||||||||||