Suresh Babu Pagadala

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromSuresh Babu Pagadala
ToMe
SubjectIFrame and DIV problem
Date15 July 2005 08:30
Hi,
Greetings for the day!

Been working on IFrame and innerHTML for sometime and facing a problem. 

The code is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style type="text/css">
    #blueitalics {color:blue;font-style:italic;font-weight:bold;}
    .special_effects {border:1px solid black}
    .word {background-color:black;color:white}
    ul {bottom-padding:0;}
    iframe {padding:0}
    div {padding:0}
</style>
</HEAD>

<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function invokeIframe() 
{
     var _x = document.getElementById('framediv'); 
     _x.innerHTML = '<iframe onload="insertIt();" src="included_content.html"'+
       'frameborder="no" width="555px" scrolling="no">';
     return true;
}

function insertIt() 
{ 
    var _y = document.getElementById('framediv'); 
    var _x = window.frames[0].document.body.innerHTML; 
    _y.innerHTML = _x; 
} 

//-->
</SCRIPT>
<div id="framediv"> 
     Before iframe loads, consider this as the content
</div> 
<a href='#' onclick='invokeIframe();return false;'>Invoke Iframe</a>
</BODY>
</HTML>


What I am trying to do is to avoid:

1. links in <iframe should open in the parent frame.
2. use styles and javascript from the parent
3. resize the height of iframe as content height varies  
etc..

Problem :
The page keeps loading and loading in FireFox.

Can you please suggest me where I went wrong.
Thanks in advance.

warm rgds,
Suresh Babu Pagadala
FromMe
ToSuresh Babu Pagadala
SubjectRe: IFrame and DIV problem
Date15 July 2005 13:49
Suresh,

> The page keeps loading and loading in FireFox.
>
> Can you please suggest me where I went wrong.
> Thanks in advance.

I cannot see anything wrong with what you are doing, so maybe it has
something to do with the other files it is loading. I will need to see the
real page online where it is failing just in case it is a server headers
issue. Unfortunately, I am just about to go on holiday for over a week, so
I will not be able to take a look at anything until I get back.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromSuresh Babu Pagadala
ToMe
SubjectIFrame and DIV problem
Date15 July 2005 17:05
AttachmentSample page
MessageDear Jones [Ed. What?!],

Thanks for your reply.  Please find attached the html code.
Please try to run this code in Firefox and the browser keeps loading the
page.  Please help me to resolve this issue.

regards,
Suresh Babu
FromMe
ToSuresh Babu Pagadala
SubjectRe: IFrame and DIV problem
Date15 July 2005 20:40
AttachmentSame page with a workaround for the Firefox bug
Suresh,

> Please try to run this code in Firefox and the browser keeps loading the
> page.

Interesting. It seems you have found a bug in Firefox. Whenever you delete
an iframe, the parent page suddenly switches into "never finish loading"
mode.

It works perfectly in Opera, IE, Safari, etc, just not Firefox.

Well, the solution is simple, but annoying. You cannot ever remove the
iframe from the page.

You will need to leave the iframe on the page. I suggest appending it to the
body, position it absolutely, and hide it with CSS. Never delete it - there
is no need, it should not matter.

I have attached an example.

Tarquin
FromSuresh Babu Pagadala
ToMe
SubjectIFrame and DIV problem
Date25 July 2005 12:44
AttachmentSample page
New DocumentDear Jones [Ed. Hrms!],

Thanks a lot for your help.  Hope you had a nice holiday.
The workaround which you'd sent me worked well with Firefox but not in IE
and I took some time to fix the issue.  
 :-) 

Now I'm back to square one where my original problem started.
innerHTML does not execute javascript blocks. So if I replace the contents from the 
<iframe> I'm not able to access events (onclick, etc ), objects like (date, etc).
 :-( 

Heard that innerHTML treats the content being replaced as a string rather than
a DOM. Please suggest me something, so that I can proceed further.


Thanks & Rgds,
Suresh Babu Pagadala
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.