Solved

Possible to getElementById with Frames?

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

747 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

9 Experts available now in Live!

Get 1:1 Help Now