JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 19th, 2004, 06:20 AM
BurhanKhan BurhanKhan is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 44 BurhanKhan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Question get innerText of iframe

Hi:

I have a problem in getting innerText of iframe.
I use this script:

var inText = document.getElementById("f1").document.body.innerText;
alert(inText); // After using this script i receive innerText of whole page, but not iframe.

Then i use this:
var inText = f1.document.body.innerText;
alert(inText); // After using this i receive error message "Access Denied"

Then i use this:
var inText = document.frames("f1").document.body.innerText;
alert(inText); // After using this i receive same error message "Access Denied"

Can any body tell me what is going wrong?

Thanks
Burhan

Reply With Quote
  #2  
Old August 25th, 2004, 10:08 AM
Jackot29 Jackot29 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Paris, FRANCE
Posts: 29 Jackot29 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 32 m 10 sec
Reputation Power: 0
Exclamation no idea on any kind of issue...

First of all, document.getElementById("f1").document.body.innerText; is equal to document.body.innerText;.

Actually, document.location gives you the main page location and f1.location, the iframe-page location.
document.body is an object, whereas f1 is an object and f1.body is undefined.

document.body.innerText gives you the whole page content, whereas f1.body.innerText & f1.innerText are both undefined !

Conclusion : I don't understand anything !

In fact, I'm sure your problem and mine
are linked.

Grrrr !

Reply With Quote
  #3  
Old November 23rd, 2004, 05:37 AM
Jackot29 Jackot29 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Paris, FRANCE
Posts: 29 Jackot29 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 32 m 10 sec
Reputation Power: 0
Lightbulb

IFRAMES INTERACTING

I have spent several months improving my webPage and, yesterday, after deep progress (and many brain nodes since July), I've finally found the so expected solution to our common problem.

I'll try to set it out to you, even if you've probably adopted an alternative option ever since then :

self.document points the mainPage out.

self.window points the documents set of the mainPage out AND the mainPage itself.

It might be the leading difference between the two reserved words document & window. window represents a document when it is not indexed but, it also represents an Array of documents when it is.

Let's consider a mainPage (which can be a frame or an iFrame itself) holding several iFrames ; self.window.length will return the number of contained iFrames as a value.

If we want to focus on iFrame #1 from the mainPage, we must call to self.window[0] but, to catch its document up we must call to self.window[0].document.

Considering all that, to have access to particular elements of iFrame #1 from the mainPage, follow this examples table indications :

IFRAME #i ELEMENT -------------------- WAY TO CALL TO FROM THE MAINPAGE
title ----------------------------------- self.window[i-1].document.title
body HTML source --------------------- self.window[i-1].document.body.innerHTML
value of an element
the identifier of wich is object1 ---------- self.window[i-1].document.getElementById("object1").value


PAY ATTENTION !

To launch the execution of a not argumented function of iFrame #1 named iFrame#1_FCT() from the mainPage, man has to call to self.window[0].iFrame#1_FCT(); as well as document.mainPage_FCT() is not a valid formulation.

To go deeply from all that, launching an argumented function of iFrame #1 (with arguments also contained in iFrame #1) from the mainPage, the correct formulation is based on this schema :

self.window[0].iFrame#1_argumentedFCT( self.window[0].document.getElementById("iFrame#1_argument").value );

where iFrame#1_argument can be the identifier of a valued div.

This solution to our problem is valid for IE as well as for NS5+ (I can't test it with NS4).
I've tried to explain it more efficiently in this few pages.

Hope it could be usefull.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > get innerText of iframe


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway