2012-11-24, 10:40 PM
I am using the following javascript to open another window and I want to check if that window is actually open, but then I want it to call a "pause()" function if the window is not open. I have no clue how to do this even after 3 days of researching, can anybody guide me with this?
The javascript to open the window:
If that window is not open I want it to call a pause function:
Somebody replied with:
But I have no clue how to add that in, would you be able to help me please?
Please close, I got it on my own, pm me if you want the code.
The javascript to open the window:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
<script type="text/javascript">
var windowSizeArray = ["width=300,height=300",
"width=200,height=400,scrollbars=yes"];
$(document).ready(function () {
$('#newWindow').click();
window.open($('#newWindow').attr('href'), 'window name', 'window settings')
$('.newWindow').click(function (event) {
var url = $(this).attr("href");
var windowName = "popUp"; //$(this).attr("name");
var windowSize = windowSizeArray[$(this).attr("rel")];
window.open(url, windowName, windowSize);
event.preventDefault();
});
});
</script>
If that window is not open I want it to call a pause function:
<a href="javascript:void(0);" onclick="pause();"><img name="b1" src="system/modules/surf/stop.png" border="0" alt="Pause" title="Pause" style="position:absolute;top:28px;margin-left:5px"></a>
Somebody replied with:
The function window.open() returns a handle to your newly created window, which has a closed property. This property is true if the new window has been closed:
var popuphandle=window.open(...);
alert(popuphandle.closed);
If you need to monitor the status of the window continuously, use window.setInterval():
window.setInterval(function()
{
if (popuphandle.closed) pause();
}, 1000);
But I have no clue how to add that in, would you be able to help me please?
Please close, I got it on my own, pm me if you want the code.