473,569 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting a document object from a form reference?

Hello,

Is it possible to get a reference to a form's document object
exclusively from a reference to the same form? I mean, for example, if I
have:

var f1 = document.forms["form1"];
var f2 = parent.document .forms["form2"];
var f3 = top.document.fo rms["form3"];

Is it possible to get the document object of each form only from these
vars? Is there something like, i.e., a "form.docum ent" property?

TIA,

Llorenc Sole
Feb 22 '06 #1
3 1394
VK

Llorenc Sole wrote:
Is it possible to get the document object of each form only from these
vars? Is there something like, i.e., a "form.docum ent" property?


if ('undefined' != typeof myForm.ownerDoc ument) {
var doc = myForm.ownerDoc ument;
}

This property check only for ancient browsers. If you make environment
check somewhere else, then simply:

var doc = myForm.ownerDoc ument;

Feb 22 '06 #2
Hi,
var doc = myForm.ownerDoc ument;


Wow, exactly what I was looking for. Thank you!

Llorenc
Feb 22 '06 #3
VK wrote:
Llorenc Sole wrote:
Is it possible to get the document object of each form only from these
vars? Is there something like, i.e., a "form.docum ent" property?
if ('undefined' != typeof myForm.ownerDoc ument) {
var doc = myForm.ownerDoc ument;
}


Reading this I thought you could get a posting right once. But:
This property check only for ancient browsers. ^^^^^^^^^^^^^^^ ^
Such as IE for Windows < 6.0, non-Windows IE, and Opera < 7.0, I suppose.
If you make environment check somewhere else, then simply:

var doc = myForm.ownerDoc ument;


Which is not any kind of check at all.
PointedEars
Feb 22 '06 #4

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

Similar topics

1
3402
by: mark.reichman | last post by:
I have text fields in my form with the same name. I can reference the value of these fields in IE 6.0 like with document.form.field.value. However, netscape 4.7 seems to croak. Why? What is the equivalent way to get the value in netscape 4.7.
4
13378
by: Don W. | last post by:
Is it possible to open a browser window from a javascript for the purpose of gathering user input on a form and then use data from the form in the javascript? How do you get the data from the form into the script? Don W.
10
2301
by: Chuck | last post by:
Hi! Any ideas as to how I can get ride of the script error undefined variable "Exp_Month"? I am trying to get this drop down list to default to the current month as opposed to 01. Thank you in advance.
6
22500
by: Martin | last post by:
I'd like to be able to get the name of an object instance from within a call to a method of that same object. Is this at all possible? The example below works by passing in the name of the object instance (in this case 'myDog'). Of course it would be better if I could somehow know from within write() that the name of the object instance was...
12
10140
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical scrollbar, you get the height of the entire document, screwing up any chance of centering a window in the browser using these values. Is there a...
15
3296
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange) { var range = document.selection.createRange(); if (range.parentElement() == element) range.text = '<' + tag + '>' + range.text + '<\/' + tag +...
21
3946
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't...
4
4574
by: chippy | last post by:
I am finding that when I use the cloneNode method to copy an HTML element that contains a <script> tag, the contents of the <script> tag, (ie. the javascript) are removed. If I do this: var form1 = document.getElementById(sID).firstChild.cloneNode(true); alert(form1.outerHTML); I can see the empty <script> tags. I am wondering if there...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
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...
0
7926
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. ...
0
8138
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...
1
5514
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...
0
5223
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...
0
3657
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...
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
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...

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.