473,672 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

form target & IE

Hi all,

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?

Thanks in advance for your help.

Thomas

Feb 23 '06 #1
2 6478
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)
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.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)


Feb 23 '06 #3

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

Similar topics

4
4442
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 part, the scripts were created with http://phpcodegenie.sourceforge.net/
2
2290
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 fields. Second, it doesn't submit the information (it's supposed to send it to mySql and email it to me.) and lastly, it doesn't bring up the thankyou.php after submitting the form. I don't know enough about PHP to find the problem. If someone could...
7
20916
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 the asp page. When I use _blank target there is no problem, either I use GET or POST method. But when I use _search target, only GET method works.
1
1986
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 another window and submit the typed text to different action/script to give a preview. So far I have done this (removing the excess formatting HTML for clarity): ---------- <SCRIPT language="JavaScript" type="text/javascript"> function...
2
2128
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, I want to do this: tmpFormObj = new Form(); tmpFormObj.target = document.location; // For example. tmpFormObj.method = "POST";
15
10845
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 code works fine for all of column A, but on column B it uses the Speech and Sound from column C. Thank you for your help. Private Declare Function sndPlaySound Lib "winmm.dll" _ Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
3
1691
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. It works quite nicely and I like the way it works. The problem is I am working on a site where the html needs to validate using STRICT. This form doesn't validate with STRICT because I use a name on the form and not and id. Could someone show me...
1
1682
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 & use it's id for the target property of the hyperlink object. please assist
4
3250
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 (inputs, textareas, etc.) normally. The file upload mechanism is structured in the way that it sets form's enctype (multipart) and target to iframe dynamically and then resets to old values right after submit() method. This works ideally in most...
0
8418
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8944
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8844
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7469
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6254
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4239
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1835
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.