Small (?) script change needed.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jaap

    #1

    Small (?) script change needed.

    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.get ElementById) {
    return document.getEle mentById(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.disp lay = (oDiv.style.dis play=='none') ? 'block' : 'none';
    if( storedDiv && storedDiv != oDiv ) { storedDiv.style .display = 'none';
    } storedDiv = oDiv;
    }
    //--></script>


    in <body>tag
    <span style="cursor:h and; cursor:pointer" onclick="toggle Info('ans0');">[color=blue][color=green]
    >> Hide/show content[/color][/color]
    </span><br><br>
    <div id="ans0">

    content

    </div>



  • Jaap

    #2
    Re: Small (?) script change needed. SOLVED

    solution: using a different script...

    <script type="text/javascript">
    /* This goes in the head section */
    window.onload = function() {
    document.getEle mentById('hidea ble').style.dis play = 'block'; }

    function toggle(link, divid) {
    var div = document.getEle mentById(divid) ;
    if (div.style.disp lay == 'none') {
    div.style.displ ay = 'block';
    link.innerHTML = 'Hide Sponsors';
    } else {
    div.style.displ ay = 'none';
    link.innerHTML = 'Show Sponsors';
    }
    }
    </script>

    [color=blue][color=green]
    >> <a href="#hideable " onclick="toggle (this, 'hideable'); return[/color][/color]
    false;">Hide Sponsors</a><br><br>
    <div id="hideable">

    content

    </div>

    "Jaap" <jaapNOSPAM@vel dhorst.nl> schreef in bericht
    news:PC%Cc.1659 3$3N6.3337@amsn ews05.chello.co m...[color=blue]
    > Hi,
    >
    > For a hobby site, I found this script and I'd like it to work the other[/color]
    way[color=blue]
    > 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.get ElementById) {
    > return document.getEle mentById(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.disp lay = (oDiv.style.dis play=='none') ? 'block' : 'none';
    > if( storedDiv && storedDiv != oDiv ) { storedDiv.style .display = 'none';
    > } storedDiv = oDiv;
    > }
    > //--></script>
    >
    >
    > in <body>tag
    > <span style="cursor:h and; cursor:pointer" onclick="toggle Info('ans0');">[color=green][color=darkred]
    > >> Hide/show content[/color][/color]
    > </span><br><br>
    > <div id="ans0">
    >
    > content
    >
    > </div>[/color]


    Comment

    Working...