We help IT Professionals succeed at work.

Object vs iframe: why this code is working for IE offline and not online?

Dada44
Dada44 asked
on
Hi all,

I want to show a webpage inside of my page. I'd be using an iframe but it has to validate w3c  XHTML 1.0 Strict  and wai. So I go for object instead.

The code has to work in all modern browsers including Internet Explorer 6, 7, and 8.

And here are my tries:

Please have a look to the chunks of code below. Each is a version of code to make object work.

Using Firefox and Safari:
OFFLINE:
#1 works
#2 woks
# 3 dont work, shows: "The object can't be rendered"  
#4 works

ONLINE: the same as when offline.

Using Internet Explorer:
OFFLINE (----after accepting the alert to show blocked content----):
all the versions of code work!

ONLINE:
None of the versions work!! It shows something like an empty iframe, a blank with no active scrollbars around.
And here's the problem, I need a version of the code to work online and in all browsers.

Please give me a hand here, I have to show this working very soon and I don't have a clue on what is happening.

Thanks a lot

<!-- #1 -->
<object codebase="http://www.google.com" type="text/html" data="http://www.google.com"  style="width:526px;height:447px" standby="Information">
   <img src="http://3dshaders.com/shaders/Earth-1tex.jpg" alt="the earth" longdesc="earth.html" />
</object>
</div>

<!-- #2 -->
<object  classid="http://www.google.com"  codebase="http://www.google.com" data="http://www.google.com" type="text/html" style="width:516px;height:437px" >
	<object  codebase="http://www.google.com" data="http://www.google.com" type="text/html" style="width:516px;height:437px" >
		alt : <a href="apage.html">more information</a>
	</object> 
</object>

<!-- #3 -->
<object data="http://www.yahoo.es" classid="clsid:235336920-03F9-11CF-8FD0-00AA00686F13"  type="text/html" id="editorWindow" style="width:30em;height:10em;">
<p>Sorry. The object can't be rendered .</p>
</object> 

<!-- #4 -->
<object classid="clsid:235336920-03F9-11CF-8FD0-00AA00686F13"   codebase="http://www.google.com" data="http://www.google.com" type="text/html" style="width:516px;height:437px" >
	<object  codebase="http://www.google.com" data="http://www.google.com" type="text/html" style="width:516px;height:437px" >
		alt : <a href="apage.html">more information</a>
	</object> 
</object>

Open in new window

Comment
Watch Question

I would use server side includes personally but if you can't do that follow this.

http://aplus.rs/web-dev/insert-html-page-into-another-html-page/

Pay attention to the conditional statements. You need to use them to prevent it dying in firefox.

Author

Commented:
Thanks a lot for answering Daemon_Byte.

I've tried the code you suggest in the way I show in the code attached below, and it works for Firefox but not for IE.

Please can you have a look at the code and tell me if I'm missing anything?

I've uploaded it here:
http://www.psoetv.es/mail/5.html
As I said, I can see google's page with FF but nothing is show with IE :(((

Thanks a lot once again
<body style="border:0;overflow:visible">

  
      <!--[if IE]>
   
      <object classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" data="http://www.google.com">
   
      <p>backup content</p>
  
      </object>
  
      <![endif]-->
  
       
  
      <!--[if !IE]> <-->
  
      <object type="text/html" data="http://www.google.com">
   
      <p>backup content</p>
  
      </object>

      <!--> <![endif]-->



  </body>

Open in new window

I could not figure out why it was not working in Ie6 and 7 however IE8 accepts code the way firefox and other browsers like it. So the only solution I could think of was using both iframes and objects like exampled here

http://robertneve.me.uk/test.html

Author

Commented:
Thanks Daemon_Byte.

Not working as object in IE8 for me :(
Anyway, I'm shocked, why is that IE people have not figure out a way of implementing object yet ?

Really? It worked in my IE 8 both at work and at home. Wait I figured something else out, seems IE8 doesn't like objects fetching remote code. It worked when fetching a local html file but not remote. I guess this is a security thing. I assume you have a scripting language on your host so a very simple script could be used to act as a proxy. In the case of php something like

fetch.php
<?php
echo file_get_contents('http://www.google.com');
?>

 <object type="text/html" data="fetch.php">

That sort of thing. If you need lots of different urls you can modify fetch so the url is passed in via get.

Author

Commented:
thanks !!