Some JS code doesn't work in IE - Programming - HWzone Forums
adplus-dvertising
Skip to content
  • Create an account
  • About Us

    Hello Guest!

     
    Please note - in order to participate in our community, comment and open new discussions, you must join as a registered member.

    Our members enjoy many advantages, including the ability to participate in discussions, enjoy raffles and promotions for members of the site, and receive our weekly content directly by email.

    Do not like being harassed by email? You can register for the site but do not submit your registration to the weekly email updates.

Some JS code does not work in IE


BURTON

Recommended Posts

Anyone have any idea why this code doesn't work in IE and FF Yes?

function makeObject () {
var browser = navigator.appName;
if (browser == "Microsoft Explorer ") {
var obj = new ActiveXObject ("Microsoft.XMLHTTP");
Else {}
var obj = new XMLHttpRequest ();
}
obj.overrideMimeType ('text / xml');
return obj;
}

var request = makeObject ();
var which;
var id = 0;

function getPage (which) {
document.getElementById ('nex'). disabled = true;
document.getElementById ('pre'). disabled = true;
id = which? id + 1: id-1;
request.open ('GET', 'find.php? id =' + id, true);
request.send (null);
request.onreadystatechange = parseAns;
}

function parseAns () {
if (request.readyState == 4) {
var xmldoc = request.responseXML;
var userid = xmldoc.getElementsByTagName ('id'). item (0) .firstChild.data;
id = parseInt (userid);
var username = xmldoc.getElementsByTagName ('name'). item (0) .firstChild.data;
var usermail = xmldoc.getElementsByTagName ('email'). item (0) .firstChild.data;
var usersrc = xmldoc.getElementsByTagName ('src'). item (0) .firstChild.data;
var total = xmldoc.getElementsByTagName ('total'). item (0) .firstChild.data;

document.getElementById ('my_div'). innerHTML = 'User name:' + username + ' Email: '+ usermail +' ';
if (userid <total) {
document.getElementById ('nex'). disabled = false;
}
if (userid> 1) {
document.getElementById ('pre'). disabled = false;
}
}
}

IE returns error:

line 21 char 5

request is null or not an object

Link to content
Share on other sites

ארכיון

This discussion has been archived and new comments can not be added.

×
  • Create new ...

At the top of the news:

new on the site