Close popup with javascript
Question:
Is there a javascript function to close the popup, so that I can attach it to a button within the page loaded within it. Reloading the page is not an option, as I'm working with loads of ajax panels, which would then be reset.
Answer:
You can easily close the popup window by following the next steps:
- Give your layer popup window a name. You can do this in the Adv Layer Popup options. make sure it starts with capital letter, like MyWindow
- Create a button or link that you want to use for closing
- Add the behavior call javascript on the onclick of the button or link
- use the following javascript:
cDMXPopupWindow.closeWindow('dmxPopupMyWindow')
Note: As you can see I've prefixed the window name with dmxPopup - this is necessary so don't forget it!
Note2: If you want to put the close command in the layer popup window self you must prefix it with parent:
parent.cDMXPopupWindow.closeWindow('dmxPopupMyWindow')
DISCLAIMER:
This is extra complimentary content which purpose is to show additional usage that is not part of the product, i.e. it suggests tips for extending the functionality of the product by the users themselves.
It is provided "as is", without warranty of any kind, express or
implied , including but not limited to the warranties of
merchantability, fitness for a particular purpose and nonfringement of
third party rights.
DMXzone does not take responsibility to
support the suggested content to be fully compatible and working as
intended and does not provide support for extended functionality which
is not included in the current release of the extension.
It is highly recommended that only more advanced developers use it.
Comments
Close and refresh parent
Hello George, Thanks for the snippet.
I want to be able to use this but in a thank you page. i.e I have a popup layer with an insert behaviour. when that insert is submitted the user is taken to a thank you page shown inside the pop up layer.
What I would be grateful for is help to close my thank you page after 2 seconds and refresh the parent page. I add below what I have tried but couldnt get it to work. below closes the p[op up layer but does not refresh the parent.
Cheers
Kenny
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8"">
<title>Untitled Document</title>
<script>
window.onload=init;
function init()
{
setTimeout("parent.cDMXPopupWindow.closeWindow('dmxPopupMYWINDOW'); top.location.reload(true);",2000);
}
</script>
</head>
<body>
thanks you
</body>
</html>
You must me logged in to write a comment.