Can I change the data of this object via JavaScript? For example by clicking on a link?
At the moment "main.htm" is shown in the object. I would like to show "page1.htm" in the object by clicking on a link in the page.
When I am in the object, I can manage this with window.document.location, but when I'm working OUTSIDE the object I'm kinda stuck...
I would appreciate any help.
Please do not propose to use an iframe, because I have to use the <object>.
Thanks for any help in advance!
If you want to display a page inside another page then you should be using an iframe. Besides that you are using the name attribute which is depreciated, so to be valid you should also be using a transitional DTD.
Every fight is a food fight when you’re a cannibal.
The name attribute is NOT deprecated!
The w3schools website says it is valid in Strict, Transitional and Frameset!
And if you can change the source page in the <object> from within, you can also do this from outside, I'm just looking for the code.
Besides, an iframe doesn't work in all browsers, an object does!
you mean without reloading the whole page? Or just the one that's inside the object?
When I do document.location=... from the page within the object, it works.
If this works, there has to be some code to do this from the page where the object is in?
You have to reload the whole page that contains the object.
You can change it's width and height, but not the contents of the object.
Try using this code:
Code:
function ChangeIt() {
var aO=document.getElementsByTagName('object');
for(var i=0; i<aO.length; i++) {
if(aO[i].getAttribute('name')=="main") {
aO[i].setAttribute('data', 'another.htm');
}
}
}
You can change the height by changing setAttribute
Bookmarks