Lethal Possum wrote on 23 feb 2006 in comp.lang.javascript
:
I'm trying to make the following script work on Internet Explorer:
function choose_target(form) {
if (form.popup.checked == true) {
form.target = '_blank';
} else {
form.target = '_self';
}
return true;
}
This works fine in Firefox but IE says the form object has no target
property! I thought the target property was pretty standard? Is there
something I don't get here?
This works fine in IE6:
==========================
<form target='zzz'
onsubmit=
'this.target="_blank";alert(this.target);return false;'>
<input type=submit>
</form>
==========================
'form' is a reserved word, not to be used as a variable!
Try:
<form onsubmit='choose_target(this)'>
and:
function choose_target(theForm) {
if (theForm.elements['popup'].checked)
theForm.target = '_blank';
else
theForm.target = '_self';
}
or:
function choose_target(theForm) {
theForm.target =
(theForm.elements['popup'].checked)
? '_blank'
: '_self';
}
or:
function choose_target(theForm) {
with (theForm) {
target =
(elements['popup'].checked)
? '_blank'
: '_self';
}
}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)