是否可以在触发器再次调用打开框架(Firefox)后将焦点放在框架上? [英] Is it possible to put focus on frame after trigger to open frame is invoked a second time (Firefox)?

查看:128
本文介绍了是否可以在触发器再次调用打开框架(Firefox)后将焦点放在框架上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Firefox中遇到问题。我的研究到目前为止是告诉我,有没有一个可靠的方法来处理我的问题,但我想问,以防万一。

我有以下javascript / jquery打开一个新的窗口,通过按下我的页面上的按钮触发:

  alipayTransactionModalTrigger.click(function(){
NIWindow = window.open(<! - ALIPAY_CONF_REDIRECT_URL - >,NI payment);
alipayTransactionModal.dialog(open);
});

在Chrome和Firefox中,这会打开一个新框架,并且框架将会获得焦点。这可以。但是,如果用户将此新框架打开并返回到我的原始页面。他们能够点击按钮来再次触发这个事件。如果发生这种情况,新框架应该重新加载,但在Firefox中,新框架不会在此刷新上拉焦。我不知道为什么它会把焦点放在最初的新的帧加载上,但是如果帧被相同的事件触发器刷新,就不会拉焦。我还没有勇气,在IE浏览器中检查...



这是你不能可靠控制的东西之一吗?还是有办法做到这一点?请注意,我已经尝试使用NIWindow.focus()之后的初始窗口打开上面的代码行。没有运气。

我相信我读了一些关于可能使用警报的东西,但是我不确定如何实现所描述的解决方案,而且我读到它有点像hacky的解决方案。

我可以随时打开一个新窗口_blank,这将确保焦点,但新打开的框架网址使用基于父窗口。我无法访问该代码,因此我无法添加检查以确保数据匹配,直到获得此重定向的响应。

解决方案

给每个新的窗口一个新的名字。您是否有重复使用NI payment name?的理由。



如果您的代码依赖于此窗口名称应该考虑直接传递窗口引用(NIWindow)而不是名称。一般来说,注入/传递你的依赖关系,而不是依靠魔术超级全局是一个更好的方法。


I am having an issue in firefox. My research so far is telling me that there is not really a reliable way to deal with my problem, but I am wanting to ask just in case.

I have the following javascript/jquery to open a new window triggered by pressing a button on my page:

alipayTransactionModalTrigger.click(function() {
     NIWindow=window.open("<!--ALIPAY_CONF_REDIRECT_URL-->", "NI payment");
     alipayTransactionModal.dialog("open");
  });

In Chrome and Firefox, this opens a new frame, and the frame gets focus. This is fine. However, if a user leaves this new frame open, and comes back to my original page. They are able to hit the button to trigger this event again. If this occurs, the new frame reloads as it should, but in Firefox the new frame does NOT pull focus this on this refresh. I am not sure why it would pull focus on the initial new frame load, but not pull focus if the frame is refreshed with the same event trigger. I haven't had the courage yet to check this in IE...

Is this one of those things that you cannot reliably control? Or is there a way to do this? Note, I have tried using NIWindow.focus() after the initial window open line of code above. No luck.

I believe I read something about possibly using alerts, but I was not sure how to implement the described solution, and I read that it was a bit of a hacky solution.

I could just always open a new window "_blank", and that would assure focus, but the newly opened frame url uses parameters that are based on the parent window. I have no access to that code, so there is no way for me to add checks to make sure data matches up, until I get a response back from this redirect

解决方案

Give each new window a new name. Do you have a reason for reusing the "NI payment" name?.

If your code has dependencies on this window name you should consider passing the window reference (NIWindow) directly instead of the name. Injecting/passing your dependencies instead of relying on a magic super global is a better approach in general.

这篇关于是否可以在触发器再次调用打开框架(Firefox)后将焦点放在框架上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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