防止在页面加载时打开两次相同的窗口

编程入门 行业动态 更新时间:2024-10-09 15:19:14
本文介绍了防止在页面加载时打开两次相同的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Hye, 以下是场景: 1.用户点击链接( MainPage.aspx),然后是一个Windows弹出窗口。登录后 - >他/她在系统应用程序中输入了一些数据。 2.在完成他/她的交易之前,会发出一封电子邮件,用户点击电子邮件中提供的链接,该链接将被重定向到MainPage.aspx 。 问题: 我已经实现了一些代码:

< script type =text / javascript> var windowObjectReference = null; //全局变量 函数openFFPromotionPopup(url,name){ var height = screen.availHeight; var width = screen.availWidth; var left = 0; var top = 0; var args =width =+ width +,height =+ height +,top =+ top +,left =+ left +,toolbars = yes,scrollbars =没有,状态=无,可调整大小=无; if(windowObjectReference == null || windowObjectReference.closed) / *如果指向内存中窗口对象的指针不存在或者是否有这样的指针存在,但窗口关闭* / { windowObjectReference = window.open(url,EAZY,args); / *然后创建它。将创建新窗口,并且将被带到任何其他窗口的顶部。 * / } else { windowObjectReference.focus(); / *否则窗口引用必须存在且窗口未关闭;因此,我们可以使用focus()方法将其重新置于任何其他窗口之上。没有必要在窗口中重新创建或重新加载引用的资源。 * / }; } < / script>

< body > < script type = text / javascript > this.focus(); var objWin = window.self; objWin.open('','_ self',''); objWin.close(); openFFPromotionPopup(MainPage.aspx,EAZY) < / script > < / body >

如果用户点击同一链接打开MainPage.aspx页面,这将成功。 我试图修改代码使得它将在Page Load事件上执行,但windowObjectReference将始终为null,因为它将在每次加载页面时执行,然后它将清除所有用户会话并且用户的数据条目将丢失。 问题: 如果相同的窗口已经打开而没有刷新它如何弹出窗口它会保留用户的数据条目? (在PAGE LOAD上验证不是通过按钮点击) ************************ ************ 更新 ************************************* ****** 为了更清楚,如何使用WINDOWS NAME(EAZY)检查已在浏览器中打开,以便用户点击任何链接(可能来自他们的书签或电子邮件),现有的EAZY会弹出而不刷新?

解决方案

这个答案的反向过程。 用于打开许多弹出窗口的javascript [ ^ ]

Hye, Below is the scenario: 1. User clicks on a link (MainPage.aspx) , then a windows popup. After login -> he/she does some data entry in the system application. 2. Before finishing his/her transaction, an email come out and user clicks the link provided in the email which will be redirected to MainPage.aspx. Problem: I already implemented some code which is :

<script type="text/javascript"> var windowObjectReference = null; // global variable function openFFPromotionPopup(url, name) { var height = screen.availHeight; var width = screen.availWidth; var left = 0; var top = 0; var args = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",toolbars=yes,scrollbars=no,status=no,resizable=no"; if (windowObjectReference == null || windowObjectReference.closed) /* if the pointer to the window object in memory does not exist or if such pointer exists but the window was closed */ { windowObjectReference = window.open(url, "EAZY", args); /* then create it. The new window will be created and will be brought on top of any other window. */ } else { windowObjectReference.focus(); /* else the window reference must exist and the window is not closed; therefore, we can bring it back on top of any other window with the focus() method. There would be no need to re-create the window or to reload the referenced resource. */ }; } </script>

<body> <script type="text/javascript"> this.focus(); var objWin = window.self; objWin.open('', '_self', ''); objWin.close(); openFFPromotionPopup("MainPage.aspx", "EAZY") </script> </body>

This will be successful if user clicks at the same link to open the MainPage.aspx page. I've tried to modify the code so that it will execute on Page Load event, but windowObjectReference will always be null as it will be executed each time page loads, then it will clear all user session and the user's data entry will lost. Question: How to popup the windows if the same windows has already been opened WITHOUT REFRESHING IT and it will keep the user's data entry? (validation on PAGE LOAD not by button click) ************************************ UPDATED ******************************************* To be more clearly, how can i check using WINDOWS NAME (which is EAZY) already been opened in the browser so if user click from any links (maybe from their bookmarks or email), the exisiting EAZY will popup and not refreshing?

解决方案

Reverse process of this answer. javascript for open many popup window[^]

更多推荐

防止在页面加载时打开两次相同的窗口

本文发布于:2023-11-13 11:18:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584218.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两次   加载   窗口   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!