Grow your CSS skills. Land your dream job.

Close div when clicking outside of it…

  • # August 24, 2011 at 11:28 am

    Sounds easy I know, but here is the deal.

    I am trying to get it to work with this date picker here: http://www.nsftools.com/tips/DatePickerTest.htm

    Now I have been going back and forth, but nothing I do gets me the desired result. I just want the calendar window that pops up to close if I click outside of it. Help is much appreciated.

    Here is the link to the code: http://www.nsftools.com/tips/NotesTips.htm#datepicker

    Tri
    # September 9, 2011 at 7:03 am

    … don’t know if there is a way but I’d cheat.

    Tri
    # September 9, 2011 at 7:08 am

    … and it tries to include the div …. here it is again without greater and less signs …

    (div id=”outside” style=”display:none;”onclick=”myclose()”) (/div)

    Tri
    # September 9, 2011 at 7:30 am

    … sorry final thing which I’ve forgotten bit of script you need to get the size for the out side object

    function outside_size(){
    if(typeof window.innerWidth!=’undefined’){
    viewportheight=window.innerHeight;
    }else{
    viewportheight=document.documentElement.clientHeight;
    }
    if((viewportheight>document.body.parentNode.scrollHeight)&&(viewportheight>document.body.parentNode.clientHeight)){
    blanket_height=viewportheight;
    }else{
    if(document.body.parentNode.clientHeight>document.body.parentNode.scrollHeight){
    blanket_height=document.body.parentNode.clientHeight;}else{outside_height=document.body.parentNode.scrollHeight;
    }
    }
    var outside=document.getElementById(‘outside’);
    outside.style.height=outside_height+’px';
    }

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".