Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Showing and Hiding divs using javascript problem

    on my web page i have made it so you can click on a link and a hidden div will appear. the problem is that it only appears for a split second the dissappears again. can anyone tell me what im doing wrong?

    here eis the javascript i used

    function getObj(idvalue) {
    if (document.getElementById) this.style = document.getElementById(idvalue).style;
    else if (document.layers) this.style = document.layers[idvalue];
    }

    function replies(num) {
    var rep = 'reply' + num;
    reply = new getObj(rep);
    if (reply.style.display == 'block') reply.style.display = 'none';
    else reply.style.display = 'block';
    }

    here is the web page it is to

    http://www.geocities.com/laruwe/index.html

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    because you are using anchor elements to envoke the script, after the script is done executing the anchor reloads the page. Unless there is a default anchor action when JS is disabled, do not use anchors for script envocation. Any element can have onclick, otherwise make sure that your event handling function returns false so that the default action is interrupted
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •