Forum Moderators: not2easy

Message Too Old, No Replies

Opera 6 - Make layer hidden by default?

The script works but can't make it initially hidden?

         

JAB Creations

9:48 pm on Jun 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm working with Opera 6.06 and I'm a little baffled at why I can't get this layer to be hidden by default (and then be displayed when the user triggers the script). Keep in mind Opera 6 doesn't use block/none, it uses visible/hidden for the display property. Oh and an onload function doesn't count. ;)

- John

<html>
<head>
<script type="text/javascript">

function getRefToDiv(divID,oDoc) {
if( document.getElementById ) { return document.getElementById(divID); }
if( document.all ) { return document.all[divID]; }
if(!oDoc ) { oDoc = document; }
if( document.layers ) {
if( oDoc.layers[divID] ) {
return oDoc.layers[divID];
} else {
for( var x = 0, y;!y && x < oDoc.layers.length; x++ ) {
y = getRefToDiv(divID,oDoc.layers[x].document);
}
return y;
}
}
return false;
}

function showDiv(divID_as_a_string) {
var myReference = getRefToDiv(divID_as_a_string);
if(!myReference ) { window.alert('Nothing works in this browser'); return; }
if( myReference.style ) { myReference.style.visibility = 'visible'; } else {
if( myReference.visibility ) { myReference.visibility = 'show'; } else {
window.alert('Nothing works in this browser'); return; } }
}

function hideDiv(divID_as_a_string) {
var myReference = getRefToDiv(divID_as_a_string);
if(!myReference ) { window.alert('Nothing works in this browser'); return; }
if( myReference.style ) { myReference.style.visibility = 'hidden'; } else {
if( myReference.visibility ) { myReference.visibility = 'hide'; } else {
window.alert('Nothing works in this browser'); return; } }
}

</script>
<style type="text/css">
html, body {
background: #000;
color: #ddd;
}
#body {
background-color: transparent;
border: #bbb solid;
border-width: 40px 1px 1px 1px;
bottom: 36px;
left: 4px;
overflow: auto;
padding: 0px;
position: absolute;
right: 4px;
top: 55px;
width: 100%;
z-index: 1;
}
div.promptshow {
background-color: #000000;
border: #fff solid 1px;
color: #a7a68f;
display: hidden;
height: 298px;
left: 50%;
margin-top: -149px;
margin-left: -299px;
position: absolute;
top: 50%;
width: 598px;
z-index: 66;
}
</style>
</head>

<body>

<div id="body">
<a href="#" onmouseover="hideDiv('siteoptions');">Hide Prompt</a>
<br />
<a href="#" onmouseover="showDiv('siteoptions');">Show Prompt</a>
</div>

<!-- Site Options Prompt -->
<div class="promptshow" id="siteoptions">
<h2>Site Options</h2>
<span>This prompt should initially be hidden and then displayed after the user triggers the script.</span>
</div><!-- /Site Options Prompt -->

</body>
</html>

SuzyUK

10:12 am on Jun 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




div.promtshow {
....
display: hidden;
....
}

'hidden' is not a viable value option for the display property, it should be

visibility:hidden;

you are using the visibility property in your script so that is the property that should be set?