473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

form target & IE

Hi all,

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?

Thanks in advance for your help.

Thomas

Feb 23 '06 #1
2 6466
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)
Feb 23 '06 #2
Thank you,

You led me to my actual shameful mistake: I have an input field in my
form that is named target!

All the best,

Thomas

Evertjan. wrote:
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)


Feb 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nomen Nescio | last post by:
can anyone be so kind as to look at http://www.mysolution.ws/HYPOCRITE.php and let me know why it isn't passing the form data to http://www.mysolution.ws/insertHYPOCRITES.php for the most...
2
by: iwasinnihon | last post by:
I don't usually like to do this, but I need help. I have gone over this code and cannot figure out why it doesn't work. First of all it doesn't check to see if you have filled in the required...
7
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open...
1
by: Terence Parker | last post by:
I have a form which enables users to type in some text in a <TEXTAREA>, allowing them to use HTML. I have defined two submit buttons - one to submit as usual, but one which I would like to popup...
2
by: skubik | last post by:
I'm curious as to whether it's possible to create a Form object and populate it with form element objects, strictly in Javascript, without the need to apply the form to a document. Essentially,...
15
by: amx | last post by:
I am trying to have any cell that in any row in any column (based upon code address change) that would Speak a word if the number is Under <10 and play a sound (wav) if the number is over >10. This...
3
by: bdbeames | last post by:
Ok I have a form validation problem that I need one of you javascript ninja s to help me with. The following is a form with the javascript that I have used for the last year or two to validate. ...
1
by: ismailc | last post by:
Hi, I need help please! I have an hyperlink object which i want the navigateurl to open within the current form below the object. so is there a way to create a frame within the current form &...
4
by: vunet | last post by:
Hello, My HTML form submits some values to a hidden iframe. However, this is done for file upload fields only. After file uploading is finished I am using this form to submit all other data...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.