By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,630 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,630 IT Pros & Developers. It's quick & easy.

change the url of html document embedded inside object element.

P: 54
Hi,

I'm using object element instead of iframe to embed html document.
My code:

Expand|Select|Wrap|Line Numbers
  1. <object id="childFrame" class="innerObject" classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" type="text/html" data="index.php">  
  2.               <p>backup content</p>  
  3. </object>
  4.  
On FF the object has a contentDocument property but IE7 doesn't. How can I access the document and use location.replace for example on IE7.

Is there a tool like firebug that will let me investigate all the properties on IE?

Thanks
Jan 18 '08 #1
Share this Question
Share on Google+
7 Replies


acoder
Expert Mod 15k+
P: 16,027
On FF the object has a contentDocument property but IE7 doesn't. How can I access the document and use location.replace for example on IE7.
contentDocument is for an iframe, I think, so for IE7 you'd use window.frames[frameName].document.
Is there a tool like firebug that will let me investigate all the properties on IE?
You can try using Firebug Lite.
Jan 18 '08 #2

P: 54
I tried what you suggested but it replaces the main page url instead of the page inside the object.

My code:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=iso-utf-8" />
  5.         <title>object test</title>
  6.         <script type="text/javascript">
  7.             var test = function() {
  8.                 var frm = window.frames['childFrame'].document.location.replace('page2.html');
  9.             }
  10.         </script> 
  11.     </head>
  12.     <body>
  13.         <object  id="childFrame" name="childFrame" type="text/html" data="page1.html" width=50% height=50%> 
  14.         </object>
  15.  
  16.         <button id="btn" onclick="test()">replace object url</button>
  17.  
  18.     </body>
  19. </html>
page1.html and page2.html are test pages:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.         <title>Demo</title>
  6.     </head>
  7.     <body>
  8.         <p>empty page</p>        
  9.     </body>
  10. </html>
Jan 18 '08 #3

acoder
Expert Mod 15k+
P: 16,027
IE can't handle embedding pages with the object tag. In IE, the object tag can only embed plugins and applets. See this link for more information. You'll need to use an iframe.
Jan 18 '08 #4

P: 54
According to this he can.
Jan 18 '08 #5

acoder
Expert Mod 15k+
P: 16,027
According to this he can.
Oh, I see that you're trying to embed in a strict HTML page which means you can't use an iframe. Forget the suggestion earlier about window.frames because that obviously wouldn't work.

One option I can think of is to dynamically create another object and replace the old one using replaceChild().
Jan 19 '08 #6

P: 54
It turned out to be simple:

Expand|Select|Wrap|Line Numbers
  1. objectName.object.body
Now I'm dealing with another problem.
When a user navigate inside the inner page it makes new entries in the browser history. I guess I can't prevent that from happening.

When the user clicks on the back/forward browser history buttons the right page appears but the object tag is being reloaded.

On FF it works fine.

Any idea how to prevent it from reloading on IE?

Thanks
Jan 20 '08 #7

acoder
Expert Mod 15k+
P: 16,027
Good work on figuring out the solution to the other problem.
Now I'm dealing with another problem.
When a user navigate inside the inner page it makes new entries in the browser history. I guess I can't prevent that from happening.

When the user clicks on the back/forward browser history buttons the right page appears but the object tag is being reloaded.

On FF it works fine.

Any idea how to prevent it from reloading on IE?
This may be normal behaviour (in IE), though I'm not sure. I don't think it's possible to change this, though I'd be happy to be corrected.
Jan 21 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.