change the url of html document embedded inside object element.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dolittle
    New Member
    • Sep 2007
    • 54

    change the url of html document embedded inside object element.

    Hi,

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

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

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

    Thanks
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Originally posted by dolittle
    On FF the object has a contentDocument property but IE7 doesn't. How can I access the document and use location.replac e for example on IE7.
    contentDocument is for an iframe, I think, so for IE7 you'd use window.frames[frameName].document.
    Originally posted by dolittle
    Is there a tool like firebug that will let me investigate all the properties on IE?
    You can try using Firebug Lite.

    Comment

    • dolittle
      New Member
      • Sep 2007
      • 54

      #3
      I tried what you suggested but it replaces the main page url instead of the page inside the object.

      My code:

      Code:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      	<head>
      		<meta http-equiv="Content-Type" content="text/html; charset=iso-utf-8" />
      		<title>object test</title>
      		<script type="text/javascript">
      			var test = function() {
      				var frm = window.frames['childFrame'].document.location.replace('page2.html');
      			}
      		</script> 
      	</head>
      	<body>
      		<object  id="childFrame" name="childFrame" type="text/html" data="page1.html" width=50% height=50%> 
      		</object>
      		
      		<button id="btn" onclick="test()">replace object url</button>
      		
      	</body>
      </html>
      page1.html and page2.html are test pages:
      Code:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      	<head>
      		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      		<title>Demo</title>
      	</head>
      	<body>
      		<p>empty page</p>		
      	</body>
      </html>

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        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.

        Comment

        • dolittle
          New Member
          • Sep 2007
          • 54

          #5
          According to this he can.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by dolittle
            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().

            Comment

            • dolittle
              New Member
              • Sep 2007
              • 54

              #7
              It turned out to be simple:

              Code:
              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

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Good work on figuring out the solution to the other problem.
                Originally posted by dolittle
                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.

                Comment

                Working...