Small (?) script change needed.

J

Jaap

Hi,

For a hobby site, I found this script and I'd like it to work the other way
around. The content has to show and the visitor has to click to hide it.
Could someone help me please? I'm a total Java-newbie...

TIA
Jaap

Here's the code:

in <head>tag
<script type="text/javascript">
<!--
var storedDiv = null;
function getDiv(oID) {
if(document.getElementById) {
return document.getElementById(oID);
} else if( document.all ) {
return document.all[oID];
} else { return null; }
}
window.onload = function () {
for( var i = 0, y; y = getDiv('ans'+i); i++ ) {
y.style.display = 'none';
}
};
function toggleInfo(oID) {
var oDiv = getDiv(oID); if( !oDiv ) { return; }
oDiv.style.display = (oDiv.style.display=='none') ? 'block' : 'none';
if( storedDiv && storedDiv != oDiv ) { storedDiv.style.display = 'none';
} storedDiv = oDiv;
}
//--></script>


</span><br><br>
<div id="ans0">

content

</div>
 
J

Jaap

solution: using a different script...

<script type="text/javascript">
/* This goes in the head section */
window.onload = function() {
document.getElementById('hideable').style.display = 'block'; }

function toggle(link, divid) {
var div = document.getElementById(divid);
if (div.style.display == 'none') {
div.style.display = 'block';
link.innerHTML = 'Hide Sponsors';
} else {
div.style.display = 'none';
link.innerHTML = 'Show Sponsors';
}
}
false;">Hide Sponsors</a><br><br>
<div id="hideable">

content

</div>

Jaap said:
Hi,

For a hobby site, I found this script and I'd like it to work the other way
around. The content has to show and the visitor has to click to hide it.
Could someone help me please? I'm a total Java-newbie...

TIA
Jaap

Here's the code:

in <head>tag
<script type="text/javascript">
<!--
var storedDiv = null;
function getDiv(oID) {
if(document.getElementById) {
return document.getElementById(oID);
} else if( document.all ) {
return document.all[oID];
} else { return null; }
}
window.onload = function () {
for( var i = 0, y; y = getDiv('ans'+i); i++ ) {
y.style.display = 'none';
}
};
function toggleInfo(oID) {
var oDiv = getDiv(oID); if( !oDiv ) { return; }
oDiv.style.display = (oDiv.style.display=='none') ? 'block' : 'none';
if( storedDiv && storedDiv != oDiv ) { storedDiv.style.display = 'none';
} storedDiv = oDiv;
}
//--></script>


</span><br><br>
<div id="ans0">

content

</div>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top