Reputation: 147
I have a php page that has a button named "info". On clicking this button Im getting a new window. On appearance of this small window I want to disable all operations or clicks from my 1st window.Is it possible?
My code is: parent.php:
<form method="GET" name="myform" >
<td><input type="radio" name="radioEdit" value="<?php echo $id; ?>" /><?= $id; ?></td>
<input type="submit" value="info" formaction="edit.php" onclick="target_popup(myform,'edit.php')"/>
</form>
<script>
function target_popup(form,page)
{
window.open(page, 'formpopup', 'left=100,top=100,width=600,height=400,menubar,toolbar,resizable');
form.target = 'formpopup';
}
</script>
edit.php:
<?php
if(isset($_GET['radioEdit']))
{
$n=$_GET['radioEdit'];
echo"n=$n";
}
else
{
echo"fail";
?>
after clicking on info button this new window appears, can I disable the parent.php until the new window is closed? Please help.
Upvotes: 2
Views: 550
Reputation: 10113
this is for jquery popups
a transparent div appear after popup msg shows, and on that div disable all click events there for click events works only on popup window. I think this will be helpful to you :)
<div class="disableRightClick">
</div>
https://jsfiddle.net/kokilajs/w99Mj/64/
==============================================================
updated: below code is for window.open(url) popup
for check this solution, use server[localhost] without server chrome not work but FF may be work
parent window
<style type="text/css">
#disableRightClick{
position: absolute;
min-width:100%;
min-height:100%;
background-color:rgba(1,1,1,0.4);
z-index:99;
display: none;
}
body,html{
margin:0;
padding: 0;
}
</style>
<div id="disableRightClick"></div>
<a href="http://google.com">go to google</a>
<form method="GET" name="myform" >
<td><input type="radio" name="radioEdit" value="<?php echo $id; ?>" /><?= $id; ?></td>
<input type="submit" value="info" formaction="pop.html" onclick="target_popup(myform,'pop.html')"/>
</form>
<script>
var dis = $('#disableRightClick').on("contextmenu",function(e){
alert('click disabled');
return false;
});
dis.on("click",function(e){
alert('click disabled');
return false;
});
function target_popup(form,page)
{
var new_window = window.open(page, 'formpopup', 'left=100,top=100,width=600,height=400,menubar,toolbar,resizable');
form.target = 'formpopup';
new_window.onload = click_disable;
function click_disable() {
window.document.getElementById('disableRightClick').style.display = 'block';
}
}
</script>
popup window(edit.php)
popup window test msg
<script>
window.onbeforeunload = disableparent;
function disableparent() {
window.opener.document.getElementById('disableRightClick').style.display = 'none';
}
</script>
Upvotes: 1
Reputation: 196
I'm not sure if it's the most elegant answer, but you could set a variable within your master page, and when this info button is clicked, toggle this variable, and whenever it is toggled, disable all functionality of the page. It won't physically stop users switching back to that window, but it'll stop them being able to use anything until they've done whatever they need in the popup.
Upvotes: 0