Question:

Could anyone help me find a Javascript where I can use to open and close a section of a page in 1 website?

by  |  earlier

0 LIKES UnLike

What I want to acheive is a onepage website where I can control an area (a link) in which I can open and close without changing from the orginal page.

Please see this website for an example:

http://www.hebras.cl/

 Tags:

   Report

2 ANSWERS


  1. If you're using Dreamweaver CS3 then you're in luck. Spry widgets are build in. Otherwise, sounds like too much coding for my little brain.


  2. <html>

    <head>

    <style>

    /* class for clickable hide on/off controls */

    .hideControl {

    background-color: #DDD;

    cursor: pointer;

    font-size: 12px;

    text-align: center;

    width: 250px;

    }

    /* each hide-able content div needs its own id */

    #hider1 {

    color: blue;

    display: none;

    }

    </style>

    <script>

    function show( hcRef, pid ) {

    var d = document;

    // get a reference to the specific hide-able content

    var p = d.getElementById( pid );

    // if the div is hidden, reveal it

    if ( '' == p.style.display ||

    'none' == p.style.display ) {

    p.style.display = 'block';

    // update the control's message to suit

    hcRef.innerHTML = 'click here to hide content below';

    }

    // otherwise, the div was showing, hide it

    else {

    p.style.display = 'none';

    // update the control's message to suit

    hcRef.innerHTML = 'click here to display hidden content';

    }

    }

    </script>

    </head>

    <body>

    <!--

    - create a div/div pair for each pair of control and hide-able divs

    - by using divs for the hide-able content, you can put any type of content inside

    -->

    <div class="hideControl" onclick="show(this, 'hider1' );">click here to display hidden content</div>

    <div id="hider1"> hide-able content here </div>

    </body>

    </html>

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions