Lethal Possum wrote on 23 feb 2006 in comp.lang.javas cript:
I'm trying to make the following script work on Internet Explorer:
function choose_target(f orm) {
if (form.popup.che cked == 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(th is.target);retu rn false;'>
<input type=submit>
</form>
=============== ===========
'form' is a reserved word, not to be used as a variable!
Try:
<form onsubmit='choos e_target(this)' >
and:
function choose_target(t heForm) {
if (theForm.elemen ts['popup'].checked)
theForm.target = '_blank';
else
theForm.target = '_self';
}
or:
function choose_target(t heForm) {
theForm.target =
(theForm.elemen ts['popup'].checked)
? '_blank'
: '_self';
}
or:
function choose_target(t heForm) {
with (theForm) {
target =
(elements['popup'].checked)
? '_blank'
: '_self';
}
}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)