Solved

Possible to getElementById with Frames?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Popup to change image and store url in database 2 31
html form to write data to csv 24 97
Replace &lt; with < 14 57
Rhino javascript replace special characters 4 21
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now