lkkeepmoving
lkkeepmoving

Reputation: 2355

strange: function not defined

I have write the following in my element:

<form name="myform" method="POST" id="location">
<input type="text" name="URL" maxlength="255" size="100" value="" />
<br />
<input type="button" onclick="loadXML(this.form)" name="submit" value="Submit Query" />
</form>

Then I have defined my function loadXML() in the part in the ; but every I try to run this html, the firefox shows this:

ReferenceError:loadXML is not defined loadXML(this.form)

I have checked my code for so many times I am sure there is no spell mistakes, how does this happen? How can I correct it? Thank you!

Upvotes: 0

Views: 2638

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191729

loadXML is only available in IE. Otherwise, you want to use the DOMParser object. In fact, I would rely on that existing first:

if (typeof DOMParser !== 'undefined') {
    var dom = new DOMParser();
    dom.parseFromString(this.form, "application/xml");
}
else {
    loadXML(this.form);
}

Upvotes: 1

Related Questions