防止在页面加载时打开两次相同的窗口 [英] Preventing same windows opened twice on page load

查看:71
本文介绍了防止在页面加载时打开两次相同的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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[^]


这篇关于防止在页面加载时打开两次相同的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆