View Single Post
  #1 (permalink)  
Old August 7th, 2009, 12:14 AM
codeexploiter codeexploiter is offline
Registered User
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.