Javascript 在Firefox中使用window.Open()打开自定义URL
在Firefox88中,使用Javascript 在Firefox中使用window.Open()打开自定义URL,javascript,firefox,window.open,Javascript,Firefox,Window.open,在Firefox88中,使用window.open(customURL,'.\u parent')打开自定义深度链接URL似乎会重新加载当前选项卡?这个问题有什么解决办法吗?我是否应该使用而不是window.open()?然而,在Chrome中的行为是不同的 所需行为:window.open()打开深度链接应用程序,而web应用程序(以角度编写)继续在同一帧中工作。建议使用Iframe 一些浏览器特别厌倦了窗口。打开,因为它被严重滥用,因此被阻塞。但是,iframe是非常正常的,如果使用应用程序
window.open(customURL,'.\u parent')
打开自定义深度链接URL似乎会重新加载当前选项卡?这个问题有什么解决办法吗?我是否应该使用
而不是window.open()?然而,在Chrome中的行为是不同的
所需行为:window.open()
打开深度链接应用程序,而web应用程序(以角度编写)继续在同一帧中工作。建议使用Iframe
一些浏览器特别厌倦了窗口。打开,因为它被严重滥用,因此被阻塞。但是,iframe
是非常正常的,如果使用应用程序方案并受支持,则会产生打开应用程序的副作用
这里有一种方法你可以试试
function checkIsAppSupported(appSchemeUrl, msThreshold) {
return new Promise((resolve) => {
let docBlurOccurred = false
const iframe = document.createElement('iframe', {
src: appSchemeUrl,
style: 'display:none'
})
document.appendChild(iframe)
function onDocBlur() {
docBlurOccurred = true
}
document.addEventListener('blur', onDocBlur)
// or try the newer
// document.addEventListener('visibilitychange', onDocBlur)
setTimeout(() => {
// cleanup
iframe.remove()
document.removeEventListener('blur', onDocBlur)
resolve(docBlurOccurred)
}, msThreshold); // checks if document focus changed within ms
});
}
async function tryAppSupported() {
const isAppSupported = await checkIsAppSupported('my-app://', 500);
if (isAppSupported) {
// do something
}
}
tryAppSupported()
这意味着,如果主窗口在iframe加载时间附近失去焦点,您可以合理地假设实际的应用程序方案已加载并将焦点从当前窗口移开
例如,有一些NPM做这种事情
并且非常支持关注什么类型的操作系统检查这种行为
快乐编码。为什么要将\u parent
指定为窗口名…?@CBroe,此处\u parent用于指定在父帧中打开窗口。检查此文档中的参数值:。我知道参数的含义,我首先想知道设置中涉及的任何帧的位置,因此首先需要这样做,因为您的问题描述中没有提到这方面的任何内容。