faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 5 people (60%) answered Yes
Recently 3 of 5 people (60%) answered Yes

Entry

How can I access the elements of a form defined in a Frameset page in NS6. (works in IE and NS4x)

Apr 6th, 2008 18:54
ha mo, chandra sekhar, sven vahar,


Use "top" property to start counting from top browser window which 
contains frameset and move down to whatever frame you need. Examples:
x = top.framename.document.getElementsByTagName('body');
x = top.framename.document.forms[0].elementname.value;
So if you have frame named "guestbook" and it contains form 
named "comments" and textarea named "entry" then you can access its 
value with:
x = top.guestbook.comments.entry.value;
This is author (Chandra Sekhar) of the question again...
I think my question is interepreted in other way. I will try to explain 
the question with example. However I got the resolution.
Q : When I have a Form in the frames page, Form will not be detected in 
case of NS6.X. The following is the sample code.
<HTML>
<HEAD>
<META HTTP-EQUIV="Expires" CONTENT="0">
<TITLE> Sample page  </TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
//-->
</SCRIPT>
</HEAD>
<Form Method=Post id=MyForm name=MyForm >		
	<INPUT NAME =hdntxt1 id =hdntxt1 type=Hidden  >			
	<INPUT NAME = hdntxt2 id =hdntxt2 type=Hidden >
</Form>
<FRAMESET Cols="22%,*" language=javascript FRAMEBORDER=0 
onLoad= "RefreshAll();">	
		<FRAME SRC="sample.asp" NAME="frame1" MARGINWIDTH=0  
MARGINHEIGHT=0 NORESIZE SCROLLING=no>
		<FRAME SRC="Blank.html" NAME="frame2" FRAMEBORDER=0  
MARGINWIDTH="4" >
</FRAMESET>
</HTML>
The form that contains hidden text boxes is not accessible in the 
clientside script in case of NS6x. 
Ans: According to standards, this is illegal HTML. However this is 
supporeted in NS4.x and IE browsers. The workaround for this is as 
follows:
1. Define another frame with "0%" using cols/rows property of the 
frameset tag. Move the form that contains the hidden text boxes to this 
frame page.
2. Define a new Frame onload function if initialization is required for 
any one of these hidden text boxes. This might be required for ASP 
pages.
3. Access these form elements using "top" property.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com