By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

ActiveXObject is not working in IE

P: 1
Hi i have html page with on button,textbox and i need to validate user ID with books.xml file,the fuction is working in FF browser but not in IE8,Crome,here is the code
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5. <script type="text/javascript" >
  6. function loadXMLDoc(dname)
  7. {
  8.  
  9. if(window.XMLHttpRequest)
  10. {
  11. xhttp=new XMLHttpRequest();
  12. }
  13.  
  14. else 
  15. {
  16. xhttp=new ActiveXObject("Msxml2.XMLHTTP");    
  17.  
  18. }
  19.  
  20. xhttp.open("GET","books.xml",false);
  21. xhttp.send();
  22. xmlDoc=xhttp.responseXML;
  23.  
  24.  
  25. /*<script type="text/javascript">
  26. function validate(dname)
  27. {
  28. var xmlDoc=loadXMLDoc("books.xml");*/
  29.  
  30. var x=xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
  31. alert(x);
  32.  
  33. /*var hint=document.write(x[0].childNodes[0].nodeValue);*/
  34. y=document.getElementById('fname').value;
  35.  
  36. if (x===y)
  37. {
  38. return true;
  39. }
  40. else
  41. {
  42. alert("Wrong ID,please try again...!!!");
  43. return false;
  44. }
  45.  
  46. }
  47. </script>
  48. </head>
  49. <body style="background-color:#FAFFF6">
  50.  
  51. <form action="content1.htm" method="post" >
  52. <table align="center" style="border:solid;color:brown;font-family:tahoma;font-weight:bold;"> 
  53. <tr>
  54. <td>Enter Employee ID</td>
  55. <td><input type="text" id="fname"></td>
  56. </tr>
  57. <tr>
  58. <td></td>
  59. <td ><input type="submit" value="Enter" style="font-family:tahoma;font-weight:bold;border:solid;" onclick="return loadXMLDoc()"/></td>
  60. </tr>
  61. </table>
  62. </form>
  63. </body>
  64. </html>
  65.  
Attached Files
File Type: txt login.txt (1.3 KB, 245 views)
Apr 11 '11 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
What doesn't work? What do you expect to happen and what happens instead in Chrome, IE, etc.?
Apr 14 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.