473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting HTML Contents of a Frame

When I run
Expand|Select|Wrap|Line Numbers
  1. alert("page contents:" + content.document.documentElement.innerHTML);
  2.  
I am able to pull the content. I see something like this

Expand|Select|Wrap|Line Numbers
  1. page contents:<head><title>A Title</title>
  2. <FRAMESET ROWS="75,*">
  3. <FRAME SRC="sample2.html" NAME="nav" title="Main Navigation">
  4. <FRAME SRC="sample.html" NAME="body" title="Main Content">
  5. </FRAMESET>
  6.  
What I want to get is the HTML inside of one of the frames,
specifically "sample.html".

I am able to get to an HTMLFrameElement object using
"content.document.getElementsByName("body")[0]", but have not been
able to grab the content, and I'm not so sure that's the right path to
be taking to get the content.

Can somebody please help me out?

--Dale--

Jun 15 '07 #1
6 10966
On Jun 15, 7:44 am, "DRS.Use...@sengsational.com"
<DRS.Use...@sengsational.comwrote:
When I run
Expand|Select|Wrap|Line Numbers
  1. alert("page contents:" + content.document.documentElement.innerHTML);
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. I didn't know "content" would access the window object. I think it is
  4. far more standard to write window.document....
  5.  
  6.         
  7.  
  8.  
  9.  
>
I am able to pull the content. I see something like this

Expand|Select|Wrap|Line Numbers
  1. page contents:<head><title>A Title</title>
  2. <FRAMESET ROWS="75,*">
  3. <FRAME SRC="sample2.html" NAME="nav" title="Main Navigation">
  4. <FRAME SRC="sample.html" NAME="body" title="Main Content">
  5. </FRAMESET>
  6.  

What I want to get is the HTML inside of one of the frames,
specifically "sample.html".
window.body.documentElement.innerHTML

where "body" is the NAME attribute of the frame. Probably better to
choose a different name since "body" has special meaning in a
document.
Peter

Jun 15 '07 #2
Thank you very much for the reply Peter. Please see comments below.

On Jun 15, 1:42 pm, Peter Michaux <petermich...@gmail.comwrote:
On Jun 15, 7:44 am, "DRS.Use...@sengsational.com"

<DRS.Use...@sengsational.comwrote:
When I run
[code]
alert("page contents:" + content.document.documentElement.innerHTML);

I didn't know "content" would access the window object. I think it is
far more standard to write window.document....
I could have been more descriptive. In my case, "window.document..."
doesn't work, and "content.document..." does (at least for the page
with the frameset). The likely wild card: I am running from an
overlay in a Firefox extension.
I am able to pull the content. I see something like this
Expand|Select|Wrap|Line Numbers
  1.  page contents:<head><title>A Title</title>
  2.  <FRAMESET ROWS="75,*">
  3.  <FRAME SRC="sample2.html" NAME="nav" title="Main Navigation">
  4.  <FRAME SRC="sample.html" NAME="body" title="Main Content">
  5.  </FRAMESET>
  6.  
What I want to get is the HTML inside of one of the frames,
specifically "sample.html".

window.body.documentElement.innerHTML

where "body" is the NAME attribute of the frame. Probably better to
choose a different name since "body" has special meaning in a
document.
The page, at the moment, is authored by me, and I can change "body" to
anything, but once this code gets into doing real work, it will be
somebody else's page, so if they choose "body", I'll need to deal with
it.

So here's what I see so far:

content.document.documentElement.innerHTML shows the page contents
(the page with the frameset).

Based on your suggestion to use "window" instead of "content", I tried
this, which should work, but doesn't:

window.document.documentElement.innerHTML says "undefined".

content.body.documentElement.innerHTML gives a TypeError: content.body
has no properties.

I renamed "body" to see if it made any difference...

content.dale.documentElement.innerHTML says content.dale has no
properties

window.dale.documentElement.innerHTML says window.dale has no
properties

Any more ideas for me?

--Dale--

Jun 15 '07 #3
Anybody? This javascript code is running from a Firefox plugin, if
that makes any difference.

On Jun 15, 10:44 am, "DRS.Use...@sengsational.com"
<DRS.Use...@sengsational.comwrote:
When I run
Expand|Select|Wrap|Line Numbers
  1. alert("page contents:" + content.document.documentElement.innerHTML);
  2.  

I am able to pull the content. I see something like this

Expand|Select|Wrap|Line Numbers
  1. page contents:<head><title>A Title</title>
  2. <FRAMESET ROWS="75,*">
  3. <FRAME SRC="sample2.html" NAME="nav" title="Main Navigation">
  4. <FRAME SRC="sample.html" NAME="body" title="Main Content">
  5. </FRAMESET>
  6.  

What I want to get is the HTML inside of one of the frames,
specifically "sample.html".

I am able to get to an HTMLFrameElement object using
"content.document.getElementsByName("body")[0]", but have not been
able to grab the content, and I'm not so sure that's the right path to
be taking to get the content.

Can somebody please help me out?

--Dale--

Jun 16 '07 #4
On Jun 15, 10:44 am, "DRS.Use...@sengsational.com"
<DRS.Use...@sengsational.comwrote:
When I run
Expand|Select|Wrap|Line Numbers
  1. alert("page contents:" + content.document.documentElement.innerHTML);
  2.  

I am able to pull the content. I see something like this

Expand|Select|Wrap|Line Numbers
  1. page contents:<head><title>A Title</title>
  2. <FRAMESET ROWS="75,*">
  3. <FRAME SRC="sample2.html" NAME="nav" title="Main Navigation">
  4. <FRAME SRC="sample.html" NAME="body" title="Main Content">
  5. </FRAMESET>
  6.  

What I want to get is the HTML inside of one of the frames,
specifically "sample.html".

I am able to get to an HTMLFrameElement object using
"content.document.getElementsByName("body")[0]", but have not been
able to grab the content, and I'm not so sure that's the right path to
be taking to get the content.
The property I was looking for was "contentDocument". Here is the
solution:

content.document.getElementsByName("body")
[0].contentDocument.documentElement.innerHTML

which I was able to assemble once I found the "right" API
documentation here: http://www.xulplanet.com/references/...meElement.html

Do I get a "5 of 5" for answering my own question?

--Dale--

Jun 17 '07 #5
On Jun 17, 7:01 am, "DRS.Use...@sengsational.com"
<DRS.Use...@sengsational.comwrote:
On Jun 15, 10:44 am, "DRS.Use...@sengsational.com"

<DRS.Use...@sengsational.comwrote:
When I run
Expand|Select|Wrap|Line Numbers
  1.  alert("page contents:" + content.document.documentElement.innerHTML);
  2.  
I am able to pull the content. I see something like this
Expand|Select|Wrap|Line Numbers
  1.  page contents:<head><title>A Title</title>
  2.  <FRAMESET ROWS="75,*">
  3.  <FRAME SRC="sample2.html" NAME="nav" title="Main Navigation">
  4.  <FRAME SRC="sample.html" NAME="body" title="Main Content">
  5.  </FRAMESET>
  6.  
What I want to get is the HTML inside of one of the frames,
specifically "sample.html".
I am able to get to an HTMLFrameElement object using
"content.document.getElementsByName("body")[0]", but have not been
able to grab the content, and I'm not so sure that's the right path to
be taking to get the content.

The property I was looking for was "contentDocument". Here is the
solution:

content.document.getElementsByName("body")
[0].contentDocument.documentElement.innerHTML

which I was able to assemble once I found the "right" API
documentation here:http://www.xulplanet.com/references/...DOMHTMLFrameEl...

There seems to be problems getting the document object of a frame.
About half way down this page...

<URL: http://developer.apple.com/internet/webcontent/iframe.html>

Peter

Jun 17 '07 #6
On Jun 17, 1:31 pm, Peter Michaux <petermich...@gmail.comwrote:
On Jun 17, 7:01 am, "DRS.Use...@sengsational.com"
<DRS.Use...@sengsational.comwrote:
On Jun 15, 10:44 am, "DRS.Use...@sengsational.com"
The property I was looking for was "contentDocument". Here is the
solution:
content.document.getElementsByName("body")
[0].contentDocument.documentElement.innerHTML
which I was able to assemble once I found the "right" API
documentation here:http://www.xulplanet.com/references/...DOMHTMLFrameEl...

There seems to be problems getting the document object of a frame.
About half way down this page...

<URL:http://developer.apple.com/internet/webcontent/iframe.html>
For me, since my code will only run as a Firefox plug-in (hopefully
someday, that is), the typical tooth gnashing about making it run in
Redmond-flavor concurrently with other flavors doesn't apply for me.

But that link is a nice wrap-up for googlers needing to run in various
environments. Nice addition to the thread.

--Dale--

Jun 18 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tommy | last post by:
I try to train straight in PHP/HTML. I have many documentations read however unfortunately I didn´t find an answer for my problem : The HTML layout consists of three Frames: Top, Left and Body. ...
1
by: Bart Plessers \(artabel\) | last post by:
Hello, Currently developping a site, where I use some session variables. The site is located at my home computer. Because I have a dynamic IP adress, I use no-ip (www.no-ip.org) to have my...
3
by: John Chen | last post by:
I need to use iframe to create a floating frame. But the contents in the iframe is not a external html file. Rather, it will be dynamically created by jsp. How can I set the src attribute to a URL...
2
by: Nancy | last post by:
Hi Guys, I am trying to achieve "click one button and fresh two pages in one browser windows", but the following code does not work. Who has good idea? Thanks a lot. Nancy <HTML>...
12
by: Adam Lipscombe | last post by:
Folks, I need to get the contents of a form attribute. In Read/Write mode this is field, so I can use getElementById("name").value In ReadOnly this is just plain text, so I can use...
0
by: crownergis | last post by:
Hello. I'm Johnny Cash. Actually I have a bit of a problem. I have a page with an inline frame. The contents of the frame are wider than the frame (and designed that way). The newest content in...
2
by: ChrisR | last post by:
Hi folkes I have a simple html file with 2 frames, as my Help file to my DB. It consists of 3 parts: Help.htm = Is the main file with the 2 frames. Index.htm = Is the left frame as a index...
28
by: Stefan Mueller | last post by:
I can display the value of the following input box with alert(parent.MyFrame.document.MyForm.MyInput.value); But if the frame, the form or the input box doesn't exist I get of course an error...
4
by: Bob Greschke | last post by:
Hi! I want to grab the contents of a Text widget when the frame it's on gets destroyed. I tried TextWidget.bind("<Destroy>"... , but the widget is gone before the call gets made, and I'd really...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.