简体   繁体   English

如果将窗口作为选项卡打开,则window.close不起作用(Firefox 47)

[英]window.close doesn't work if window is opened as tab (Firefox 47)

var google_login_popup = "";

var social_google_login = function () {

    google_login_popup = window.open('www.google.com', "google_popup", 'width=800, height=600');

};

social_google_login();

setTimeout(function() {
  google_login_popup.close();
}, 1000);

It opens the popup in a new TAB - not window. 它会在新的TAB中打开弹出窗口 - 而不是窗口。 But .close() doesn't close the window. 但.close()不会关闭窗口。

This should work as the script opening the window is also trying to close it. 这应该工作,因为打开窗口的脚本也试图关闭它。

Note that this only applies for Firefox 47, mobile . 请注意,这仅适用于Firefox 47, 移动版

Video: https://www.dropbox.com/s/bqcf8iwm5bsw4yn/VIDEO0254.mp4?dl=0 . 视频: https//www.dropbox.com/s/bqcf8iwm5bsw4yn/VIDEO0254.mp4?dl = 0

I tested this in Firefox 47 on mobile (Android 5.1.1, Moto G) and wasn't able to replicate the behaviour using your code in a skeleton web page. 我在Firefox 47的移动设备(Android 5.1.1,Moto G)上测试了这个,并且无法在骨架网页中使用您的代码复制行为。 However, looking at the video and looking at the code in https://cdn.dorms.com/static/js/social.js there's clearly more going on than just the code you've supplied here on SO. 但是,观看视频并查看https://cdn.dorms.com/static/js/social.js中的代码,显然还有更多内容,而不仅仅是您在此处提供的代码。

Suggestions for the person with the device 有关设备的人的建议

  • Try out some skeleton code or use my page at https://www.dropbox.com/s/db08g2gmn9s8i89/38216372.html?dl=0 † to see if you can reproduce the problem. 尝试一些框架代码或使用我的页面https://www.dropbox.com/s/db08g2gmn9s8i89/38216372.html?dl=0†看看你是否可以重现这个问题。
  • Prefix the popup URL with http:// or https:// and/or make the timeout longer. 使用http://https://和/或使用更长的超时来设置弹出URL。 I doubt very much this will help but there may be some weirdness going on. 我非常怀疑这会有所帮助,但可能会有一些奇怪的现象。
  • Reset the Firefox app, if this okay with the device owner. 如果设备所有者可以,则重置Firefox应用程序。 Clear app data and start again, just to make sure there isn't something lurking. 清除应用数据并重新开始,以确保没有潜伏的东西。
  • Firefox mobile does have USB and Wi-fi remote debugging capabilities - check under Settings >> Advanced >> Scroll to the bottom to "learn more". Firefox mobile确实具有USB和Wi-Fi远程调试功能 - 请在设置>>高级>>下查看滚动到底部“了解更多”。 This would really save time trying to debug this. 这样可以节省尝试调试的时间。

† My page contains the following HTML: †我的页面包含以下HTML:

<!DOCTYPE html>
<html>
<head>
<title>Test web page</title>
<script>
var google_login_popup = "";
var social_google_login = function () {

    google_login_popup = window.open('www.google.com', "google_popup", 'width=800, height=600');

};
social_google_login();
setTimeout(function() {
  google_login_popup.close();
}, 1000);
</script>
</head>
<body>Test web page</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 window.close()在Firefox上不起作用,是否可以解决? - window.close() doesn't work on Firefox, any work around? window.close() 在 iOS 上不起作用 - window.close() doesn't work on iOS window.close() 不起作用 - 脚本只能关闭由它打开的 windows - window.close() doesn't work - Scripts may close only the windows that were opened by it 的javascript:window.close()的; 不会关闭IE 8中的标签 - javascript:window.close(); doesn't close the tab in IE 8 window.close()在iOS 8 GM种子上不起作用 - window.close() doesn't work on iOS 8 GM seed window.close()在Windows Phone IE上不起作用 - window.close() doesn't work on windows phone IE window.close()的;不在firefox中工作 - window.close(); not working in firefox 在现有的以编程方式打开的新窗口(Firefox)中,在“新标签”中打开URL无效 - Opening URL in New Tab doesn't work in existing, programmatically-opened New Window (Firefox) 有没有办法用javascript关闭firefox中的窗口/标签? (window.close不能帮助mozilla) - Is there any way to close a window/tab in firefox with javascript? (window.close is not helping with mozilla) window.close()仅在IE中有效。 如何使用javascript关闭firefox窗口中的当前选项卡? - window.close() is working only in IE. How to close current tab in firefox window using javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM