views:

667

answers:

3

My code works great in IE8, Firefox and Safari. But it doesn't work properly in Opera. What happens is that the DIV is hidden but the space occupied by the DIV remains to appear in my web-page.

<div  style=" z-index:-1;height :380; width:760; position:relative; text-align:center" id="new-add">
    <object id="banner-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" 
     width="769" height="382" top="0"> 
    <param name="movie"  value="exp.swf" /> 
    <param name="quality" value="high" /> 
    <param name="bgcolor" value="#ffffff" /> 
    <param name="wmode" value="transparent" />
    <embed src="exp.swf" wmode="transparent" quality="high" bgcolor="#ffffff" width="780" height="382"
 name="mymoviename" align="" type="application/x-shockwave-flash" 
    pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; 
    </embed> 
    </object> 
</div>

<div  id="fechar-link" style=" font-family: Verdana,Arial,Helvetica,sans-serif; font-style: normal; 
    font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; 
    font-stretch: normal; text-decoration: none; text-align:center" >
    <a href="#" onclick="
     document.getElementById('new-add').style.height =0;
     document.getElementById('banner-flash').style.height =0;
     document.getElementById('fechar-link').style.height  = 0;

     document.getElementById('new-add').style.visibility ='hidden';
     document.getElementById('banner-flash').style.visibility ='hidden';
     document.getElementById('fechar-link').style.visibility ='hidden'; "  >Close</a>
     </div>

What do I need to do, so the space occupied by the DIV disappears?

Thanks

A: 

I don't know if it will solve your problem, but you can try to use :

document.getElementById("xxx").display = "none";

instead of

document.getElementById("xxx").style.visibility = "hidden";
romaintaz
+6  A: 

You might try the style.display property:

Hide

document.getElementById('YourElem').style.display = 'none';

Show

document.getElementById('YourElem').style.display = '';

EDIT: Took PorneL comment into acocunt in this answer

Vinzz
The problem with style.display is that to undo it, you have to know whether to display the element as block or inline.
bart
@bart:That's not an insurmountable problem, since you can always check the value and store it somewhere before you set it to 'none'. Also: setting style.display to null will restore the browser's default rendering of the element.
Will Wagner
document.getElementById('YourElem').style.display ='' reverts to default (it's standards-compliant and cross-browser method)
porneL
A: 

That solved my issue.

Thanks

;)

Armadillo