DeanWhitehouse Posted May 5, 2009 Share Posted May 5, 2009 This works fine in FF and there JS debugger finds no problems, whereas in IE if i enter 3+ chars it does nothing and just says error on page , then runtime error :s Any ideas please? Site is http://www.americangangsters.org/find.php User: Test Pass: tester <script type="text/javascript"> var xmlHttp=null; function GetXmlHttpObject() { try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function stateChanged() { document.getElementById("Js").innerHTML = '<td colspan="2" id="SearchResults"></td>'; document.getElementById("SearchResults").innerHTML = "<img align='middle' src='./images/loading.gif'/>"; if (xmlHttp.readyState == 4) { document.getElementById("SearchResults").innerHTML = xmlHttp.responseText; } } function trim(str) { var s; s = str.replace(/^(\s)*/, ''); s = s.replace(/(\s)*$/, ''); return s; } function UserSearch(Find) { Find = trim(Find); if(Find.length == 0) { document.getElementById("Warning").innerHTML = ""; if(document.getElementById("SearchResults") != null) { if(document.getElementById("SearchResults").innerHTML == "<img align='middle' src='./images/loading.gif'/>") { document.getElementById("Js").innerHTML = ''; document.getElementById("SearchResults").innerHTML = ""; } } return; } else if(Find.length < 3) { document.getElementById("Warning").innerHTML = "Enter 3 or more characters to begin searching"; if(document.getElementById("SearchResults") != null) { if(document.getElementById("SearchResults").innerHTML == "<img align='middle' src='./images/loading.gif'/>") { document.getElementById("Js").innerHTML = ''; document.getElementById("SearchResults").innerHTML = ""; } } return; } else { document.getElementById("Warning").innerHTML = ""; xmlHttp = GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!, Please consider updating your browser"); return; } var url="./Ajax/FindUser.php?user="+Find; xmlHttp.onreadystatechange = stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } } function ChangeSearch(type) { if(type == true) { document.getElementById("users_username").attributes["onkeyup"].value = "UserSearch(this.value)"; docuemnt.getElementById("form1").attributes["action"].value = ""; document.getElementById("form1").attributes["onsubmit"].value = ""; } else { document.getElementById("users_username").attributes["onkeyup"].value = ""; document.getElementById("form1").attributes["action"].value = "javascript:void()"; document.getElementById("form1").attributes["onsubmit"].value = "UserSearch(document.form1.users.value)"; } } function Init() { document.getElementById("js").innerHTML = 'Search While Typing <input type="checkbox" checked="checked" onchange="ChangeSearch(this.checked)">'; } </script> </head> <body onload="Init()"> Link to comment https://forums.phpfreaks.com/topic/156975-i-fg-e-is-stupid-and-doesnt-like-me-xd/ Share on other sites More sharing options...
radi8 Posted May 5, 2009 Share Posted May 5, 2009 try this instead: function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } Link to comment https://forums.phpfreaks.com/topic/156975-i-fg-e-is-stupid-and-doesnt-like-me-xd/#findComment-826931 Share on other sites More sharing options...
DeanWhitehouse Posted May 5, 2009 Author Share Posted May 5, 2009 At the top function GetXmlHttpObject() { try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } Link to comment https://forums.phpfreaks.com/topic/156975-i-fg-e-is-stupid-and-doesnt-like-me-xd/#findComment-826933 Share on other sites More sharing options...
DeanWhitehouse Posted May 5, 2009 Author Share Posted May 5, 2009 tried still the same, its wierd cus the ajax on airport (which is the same near enough) works in IE Link to comment https://forums.phpfreaks.com/topic/156975-i-fg-e-is-stupid-and-doesnt-like-me-xd/#findComment-826942 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 I didn't know .attribute array exists. Perhaps IE isn't friendly with that? Link to comment https://forums.phpfreaks.com/topic/156975-i-fg-e-is-stupid-and-doesnt-like-me-xd/#findComment-826953 Share on other sites More sharing options...
DeanWhitehouse Posted May 5, 2009 Author Share Posted May 5, 2009 could be, know an alternative? Link to comment https://forums.phpfreaks.com/topic/156975-i-fg-e-is-stupid-and-doesnt-like-me-xd/#findComment-826955 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 Just use the dot. Example: document.forms.form1.action.value = ""; Link to comment https://forums.phpfreaks.com/topic/156975-i-fg-e-is-stupid-and-doesnt-like-me-xd/#findComment-826991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.