JavaScript and client side scripting.
Moderator: General Moderators
thiscatis
Forum Contributor
Posts: 434 Joined: Thu Jul 20, 2006 11:00 am
Post
by thiscatis » Fri May 18, 2007 8:16 pm
Hi!
IE is giving me this error or a javascript:
"IE: Object doesn't support this method or property"
It does work in Firefox.
It's about these lines:
Code: Select all
<form action="javascript:get(document.getElementById('newsletter'));" name="newsletter" id="newsletter">
<input class="field" name="email" id="email" type="text" />
<input class="button" type="button" name="button" value="Sign Up" onclick="javascript:get(this.parentNode);" />
</form>
Kieran Huggins
DevNet Master
Posts: 3635 Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:
Post
by Kieran Huggins » Fri May 18, 2007 11:25 pm
"get" isn't a built-in javascript function - maybe there was an accompanying "function get(){...}" where you grabbed the code from. Sounds like a custom AJAX function to me.
thiscatis
Forum Contributor
Posts: 434 Joined: Thu Jul 20, 2006 11:00 am
Post
by thiscatis » Sat May 19, 2007 6:59 am
The function is defined in the head tag.
It does work in Firefox!
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat May 19, 2007 7:03 am
I don't recall IE supporting "this.parentNode."
thiscatis
Forum Contributor
Posts: 434 Joined: Thu Jul 20, 2006 11:00 am
Post
by thiscatis » Sat May 19, 2007 8:25 am
Damn
Any alternatives for this:
Code: Select all
<form action="javascript:get(document.getElementById('newsletter'));" name="newsletter" id="newsletter">
<input class="field" name="email" id="email" type="text" />
<input class="button" type="button" name="button" value="Sign Up" onclick="javascript:get(this.parentNode);" />
</form>
<span id="result">
</span>
newsletter.js
Code: Select all
/ Newsletter
var http_request = false;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}
function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
document.getElementById('result').innerHTML = result;
} else {
alert('There was a problem with the request.');
}
}
}
function get(obj) {
var poststr = "email=" + encodeURI( document.getElementById("email").value );
makePOSTRequest('join.php', poststr);
}
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Sat May 19, 2007 9:03 am
feyd wrote: I don't recall IE supporting "this.parentNode."
I'm pretty sure IE supports the parentNode property. I could swear I've used it myself before plenty of times