p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional JavaScript for Web Developers 2nd edition ISBN: 9780470227800 (http://p2p.wrox.com/forumdisplay.php?f=475)
-   -   Dynamically changing the <object> element's loaded content (http://p2p.wrox.com/showthread.php?t=75589)

codeexploiter August 7th, 2009 12:14 AM

Dynamically changing the <object> element's loaded content
 
Hi All,

I am looking for a way to change and load a HTTP resource in a <object> element.

Code:

<object classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" type="text/html" data="http://www.google.com" style="width: 1000px; height: 600px;"></object>
I have code like the above in one of my test page. The above code works correctly as a result I can avoid using iframe. Now assume that on a button click I would like to change the URL mentioned in the 'data' attribute of the object element, which is not working. Refer the code mentioned below:

Code:

window.onload = function() {
    setTimeout(function() {
        var o = document.body.getElementsByTagName("object")[0]; //o.setAttribute("data", "http://www.yahoo.com");
        o.data = "http://www.yahoo.com";
        alert(o.data);
    },
    1000);
}

The alert correctly shows the new URL that I had used from the JS. But the content loaded in the object tag element does not change.

Any help related to this would be appreciated.

semiotically August 19th, 2009 06:37 AM

Please I need this code too...

I have website that currently loads several Iframes and this hurts the loading times.

What I want to be able to do is to use <object> tag to display an image to begin with and then later, if the user so wishes, to be able to convert this same <object> to display external HTML page if user clicks a link. This will really improve load times...

PLEASE POST REPLY, thanks in advance.

jpvalappil August 21st, 2009 12:58 AM

Quote:

Originally Posted by semiotically (Post 245515)
What I want to be able to do is to use <object> tag to display an image to begin with and then later, if the user so wishes, to be able to convert this same <object> to display external HTML page if user clicks a link. This will really improve load times...

I don't know why you are trying to display an image using <object> when <img> tag is specifically for that. As far as iframes are concerned <object> seems to be a meaningful solution for most of the issues iframes creates.

But sadly not much is getting for using <object> instead of iframes..

jpvalappil October 5th, 2009 08:14 AM

Though I haven't got any reply for my question here. I decided against to use the <object> element in place of <iframe> element until the browsers support them a bit more efficiently.

I have also stumbled across one such page in which the problem that I have mentioned in my first post can be solved.


All times are GMT -4. The time now is 07:45 PM.

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