Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 31st, 2004, 09:21 AM
Authorized User
 
Join Date: Oct 2004
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting InnerHtml

Hai,

  Anybody have a solution ?

  I want to load one site to an Iframe

<iframe src="http://www.google.com" name="frame1" id="frame1">
</iframe>

   Then I want to get the InnerHtml of this Iframe. So I use
following javascript.

<script language="JavaScript">
var myHTML;
var myhtml=document.frames["frame1"].document.body.innerHTML;
myHTML = myhtml.replace(/>/,"&gt;");
myHTML = myhtml.replace(/</,"&lt;");
document.getElementById('frame1').document.body.in nerHTML= myHTML;
</script>

Then I am getting an error "Access is Denied" which is in line,

var myhtml=document.frames["frame1"].document.body.innerHTML;

First I thought it is because the site is not loaded fully. But it is not the reason.

The same code is working fine when I am giving the Iframe src to our intranet pages.

Anybody can comment on this

Thanks

Ghari


 
Old December 31st, 2004, 11:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

I would guess that all you intranet pages and the page you have this code on are in the same domain ? if so the situation you report is correct, and is disabled as a security feature.
 
Old January 3rd, 2005, 09:56 AM
Authorized User
 
Join Date: Oct 2004
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.

The intranet pages and my pages are in same domain.

If I am trying pages from other domain I am getting this error

Is there is any other way for getting InnerHtml?

Ghari

 
Old January 3rd, 2005, 12:06 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Not client side, you'd need to use a server side proxy.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using innerHTML adfranklin BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 0 April 13th, 2007 01:13 AM
abusing innerHTML ophillip Javascript How-To 3 July 21st, 2005 02:21 AM
innerHTML interrupt Javascript How-To 6 July 22nd, 2004 02:18 PM
innerHTML problem higgsy Javascript How-To 2 August 7th, 2003 07:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.