Solved

Possible to getElementById with Frames?

Posted on 2006-06-30
4
630 Views
Last Modified: 2006-11-18
Is it possible to some how set a Form Elements propery with the page is it frames...?

cb=document.getElementById('something');
is fine when there is no frames, however it fails to get it when there is frames
so... how can I get an element in frames?

cb=document.frames[0].getElementById('something'); or something?
0
Comment
Question by:wildzero
  • 2
4 Comments
 
LVL 2

Assisted Solution

by:sandylaw
sandylaw earned 25 total points
ID: 17022086
This is an exerpt from http://www.quirksmode.org/ (just so you know why i'm directing you there).  It has great references...this section is (side navigation) Javascript->Frames and windows:

===================================
The three new frames are children of content because the frameset that defines them is in the content frame. So to JavaScript, the page really looks like this:
<DIGRAM SHOWN WITH FRAMES>
The user doesn't see content, but it's still there. You can refer to it in JavaScript or even in an HTML target attribute and it'll work fine.
===================================

I've not done that before, but it appears to be possible.
0
 
LVL 16

Assisted Solution

by:sam85281
sam85281 earned 100 total points
ID: 17022701
cb = top.frames.FRAME_NAME.getElementById('something');

-Sam
0
 
LVL 10

Author Comment

by:wildzero
ID: 17025551
What happens if I don't know the frame name?
0
 
LVL 16

Accepted Solution

by:
sam85281 earned 100 total points
ID: 17025921
You can just look in the index.html, default.aspx, etc page.

It'll look like:
<frame src="blah.html" NAME="FRAME_NAME" .......

You have to know the name of the frame to be able to access it.

-Sam
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question