I used pop up in my site.The problem is, when i open a pop up and go to the other page and then go back to previous page, a pop up will refresh and open again!! without any pressed! How can i fix it? I want that this pop up wont come up again by coming back to that page.
here is my Pop up code:
.......
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js" ></script>
<script type='text/javascript' src='jquery-1.2.3.min.js'></script>
<script type='text/javascript' src='menu.js'></script>
<script type="text/javascript">
function pop_up(url) {
newwindow = window.open(url, 'name', 'height=517,width=885,scrollbars=yes,toolbar=no,menubar=no,resizable=yes,location=no,directories=no,status=no,titlebar=no,left=400,top=120');
if (window.focus) { newwindow.focus() }
return false;
}
</script>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style2
{
.......
and behind code:
Page.ClientScript.RegisterStartupScript(GetType(), "popup", "pop_up('" + "PopUpEmailing.aspx" + "');", true);
One solution would be to use the window.name
property. I know this solution can lead to conflicts if another library also tries to use this. But I prefer this more then using a cookie. (You could also think over using local storage)
function displayPopUp() {
if( window.name != "popup-displayed" ) {
window.name = "popup-displayed";
... popup code ...
}
}
Instead of using Page.ClientScript.RegisterStartupScript
try the following.
<asp:Button runat="server" ID="btnTest" Text="My Button" OnClientClick="pop_up('" + "PopUpEmailing.aspx" + "')"><asp:Button>
The above will create a button and when the button will be click a client side event will be called and it will run your pop_up javascript code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.