Solved

Possible to getElementById with Frames?

Posted on 2006-06-30
4
626 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

809 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