Click here to Skip to main content
15,868,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello sir,
i wrote script for close iframe popup on escape
iframe id= "createproductframeID"
iframe modal id = "ShowCreateProduct"
parent form textbox id = "ItemCode"
C#
$("#createproductframeID").ready(function () {
       setTimeout(function () {
           $('#createproductframeID').contents().find('body').keyup(function (e) {
               if (e.keyCode == 27) {
                   $("#ShowCreateProduct").modal("hide");
                   $("#ItemCode").focus();
               }
           });
       }, 150);
   });

this only work one time
if i stay in popup for mor time its not worked/not close
my means its work sometime or not work
mostly it not work
give a solution...
thanks in advance.
Posted
Updated 19-Dec-14 0:27am
v2
Comments
Afzaal Ahmad Zeeshan 19-Dec-14 6:32am    
Chances are that there might be any other script that is controlling your application then. Because maybe after the time, the script has been loaded and prevent the Esc key event from here.

1 solution

XML
<html>
<head>
<script type="text/javascript">
    function a(event)
    {
        alert(event.keyCode);
        if(event.keyCode==27)
        {
            // OPTION 1 : START

            document.getElementById("1").style.display="none";
            document.getElementById("2").style.display="none";
            document.getElementById("3").style.display="none";

            document.getElementById("4").style.display="none";
            document.getElementById("5").style.display="none";
            document.getElementById("6").style.display="none";

            document.getElementById("7").style.display="none";
            document.getElementById("8").style.display="none";

            // OPTION 1 : END



            // OPTION 2 : START

            for(var k=1;k<=8;k++)
            {
                document.getElementById(k).style.display="none";
            }

            // OPTION 2 : END
        }
    }
</script>
</head>
<body onKeyUp="a(event);" id="bd">
        <iframe id="1"></iframe>
        <iframe id="2"></iframe>

        <iframe id="3"></iframe>
        <iframe id="4"></iframe>

        <iframe id="5"></iframe>
        <iframe id="6"></iframe>

        <iframe id="7"></iframe>
        <iframe id="8"></iframe>
</body>
</html>
 
Share this answer
 
Comments
Manish Dalwadi 23-Dec-14 3:31am    
dear i want solution in my script

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900