Asterbing wrote:[color=blue]
> In article <MPG.1df82f045394a68798971a@news.tiscali.fr>,
no@thanks.com
> says...
>[color=green]
>>Hi. I'm trying to add an OBJECT in an existing DIV after a certain
>>delay.
>>
>>[/color]
>
>
> OK, done... Uless that the html file which has to be loaded in the
> created <object> tag is well loded under Netscape 7 but not under IE6
> nor Opera : the object remains empty (without soon.htm rendered).
>
> Here is the new code :
>
> <div id="dummy" style="position: absolute; visibility: visible; top:
> 10px; left: 10px; z-index: 5; height: auto; width: 300px; padding: 5px;
> overflow: hidden;>[/color]
------------------^
You are missing the closing quote.
[color=blue]
> <script language="JavaScript"><!--[/color]
The language attribute is deprecated, type is required. HTML comment
delimiters inside script elements are useless and potentially harmful.
[color=blue]
> setTimeout(function()
> {
> var obj,elt;
>
> elt = document.createElement("object");
> elt.setAttribute("width","280");
> elt.setAttribute("height","500");
> elt.setAttribute("type","text/html");
> elt.setAttribute("data","soon.htm");[/color]
You may find it simpler to modify the properties of elt directly:
elt.style.width = '280px';
elt.style.height = '500px';
...
Though it doesn't fix the issue with IE.
[color=blue]
>
> obj = findObj("dummy");
> obj.appendChild(elt);
> },10000);
> //--></script>[/color]
The script should be outside the div that you are trying to reference.
Some browsers may not allow you to get a reference to the div until all
the content is parsed.
[color=blue]
> </div>[/color]
Why not code the object in the HTML, then hide and display it using
script by changing its style object's display or visibility property?
Users without script will see the object directly, if you don't want
that, then hide it in the HTML and know that script-less surfers will
not see it.
<div id="dummy" style="position: absolute; visibility: visible; top:
10px; left: 10px; z-index: 5; height: auto; width: 300px;
padding: 5px; overflow: hidden;">
<object id="obj_01" type="text/html" data="soon.htm" width="280"
height="500"></object>
</div>
<script type="text/javascript">
var obj = findObj('obj_01');
if (obj && obj.style) {
obj.style.visibility = 'hidden';
setTimeout(function() {
obj.style.visibility = 'visible';
}, 60000);
};
// Just for the exercise.
function findObj (id){
return document.getElementById(id);
}
</script>
--
Rob