Results 1 to 2 of 2
  1. #1
    ayushi is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default how to disable the parent window when child window is open

    hii....i want to disable the whole window by using this code in an iframe..when i clicked the link given in iframe a child window will open..and blur the parent window
    but it is not working.
    can any1 help me...
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Josh - Test</title>
    <style type="text/css">
    .opaqueLayer
    {
    display:none;
    position:absolute;
    top:0px;
    left:0px;
    opacity:0.4;
    filter:alpha(opacity=60);

    background-color: #3300CC;

    }

    .questionLayer
    {
    position:absolute;
    top:0px;
    left:0px;
    width:350px;
    height:200px;
    display:none;

    border:2px solid black;
    background-color:#FFFFFF;
    text-align:center;
    vertical-align:middle;
    padding:10px;
    }
    </style>
    <script type="text/javascript">
    function getBrowserHeight() {
    var intH = 0;
    var intW = 0;

    if(typeof window.innerWidth == 'number' ) {
    intH = window.innerHeight;
    intW = window.innerWidth;
    }
    else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    intH = document.documentElement.clientHeight;
    intW = document.documentElement.clientWidth;
    }
    else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
    intH = document.body.clientHeight;
    intW = document.body.clientWidth;
    }

    return { width: parseInt(intW), height: parseInt(intH) };
    }

    function setLayerPosition() {
    var shadow = document.getElementById("shadow");
    var question = document.getElementById("question");

    var bws = getBrowserHeight();
    shadow.style.width = bws.width + "px";
    shadow.style.height = bws.height + "px";

    question.style.left = parseInt((bws.width - 350) / 2);
    question.style.top = parseInt((bws.height - 200) / 2);

    shadow = null;
    question = null;
    }

    function showLayer() {
    setLayerPosition();

    var shadow = document.getElementById("shadow");
    var question = document.getElementById("question");

    shadow.style.display = "block";
    question.style.display = "block";

    shadow = null;
    question = null;
    }

    function hideLayer() {
    var shadow = document.getElementById("shadow");
    var question = document.getElementById("question");

    shadow.style.display = "none";
    question.style.display = "none";

    shadow = null;
    question = null;
    }

    window.onresize = setLayerPosition;
    </script>
    </head>
    <body>
    <div id="shadow" class="opaqueLayer"> </div>
    <div id="question" class="questionLayer">

    <input type="button" onClick="hideLayer();" value="Close" />
    </div>
    <h3>Modal Layer Test</h3>
    <p>Click the image below to display the "modal" layer</p>
    <img src="http://www.google.com/intl/en_ALL/images/logo.gif" alt="Test Image" onClick="showLayer();" />
    </body>
    </html>

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

Similar Threads

  1. Replies: 4
    Last Post: 02-07-2011, 09:43 AM
  2. Replies: 4
    Last Post: 01-10-2010, 08:48 AM
  3. change url in parent window from child window
    By rakesh_n_mehta in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-09-2009, 01:17 PM
  4. Parent & Child window issues......
    By jithan in forum New To Java
    Replies: 2
    Last Post: 09-20-2008, 10:21 AM
  5. disable parent window
    By ismailsaleh in forum AWT / Swing
    Replies: 1
    Last Post: 01-08-2008, 12:15 AM

Posting Permissions

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