Permalink
Browse files

fixing the ie lookupByName in trunk

git-svn-id: http://svn.getwindmill.com/trunk@1319 78c7df6f-8922-0410-bcd3-9426b1ad491b
  • Loading branch information...
1 parent e5c4168 commit 418e0136a94f53ace154a68b4b5b3292f340b88e admc committed Jun 12, 2009
Showing with 32 additions and 6 deletions.
  1. +32 −6 windmill/html/js/lib/elementslib.js
@@ -119,14 +119,40 @@ var elementslib = new function(){
//DOM element lookup functions, private to elementslib
var nodeByName = function (s) { //search nodes by name
- //sometimes the win object won't have this object
- try{
- var els = this.document.getElementsByName(s);
- if (els.length > 0) {
- return els[0];
+ var getElementsByAttribute = function(oElm, strTagName, strAttributeName, strAttributeValue){
+ var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
+ var arrReturnElements = new Array();
+ var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)", "i") : null;
+ var oCurrent;
+ var oAttribute;
+ for(var i=0; i<arrElements.length; i++){
+ oCurrent = arrElements[i];
+ oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
+ if(typeof oAttribute == "string" && oAttribute.length > 0){
+ if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
+ arrReturnElements.push(oCurrent);
+ }
+ }
+ }
+ return arrReturnElements;
+ }
+
+ if (navigator.userAgent.indexOf('MSIE') != -1){
+ var node = getElementsByAttribute(this.document, "*", "name", s);
+ if (node.length == 0){
+ return null;
+ }
+ return node[0];
+ } else {
+ //sometimes the win object won't have this object
+ try{
+ var els = this.document.getElementsByName(s);
+ if (els.length > 0) {
+ return els[0];
+ }
}
+ catch(err){};
}
- catch(err){};
return null;
};

0 comments on commit 418e013

Please sign in to comment.