English 中文(简体)
如何打开并关闭窗口而不因弹出而被堵住?
原标题:How to open and then close a window without getting blocked as a popup?

I want to direct a customer in an e-commerce site to pay via Paypal s website. I would like the payment to be done in a new tab/window so the customer doesn t lose the current state of the web page he/she is at.

为了让 Paypal 窗口打开而不被屏蔽, 我正使用目标= "_blank" 的锁定。 除了事实外, 这正在完全有效, 在 Paypal 付款完成后, 我无法关闭它, 因为 window. close () 不适用于未通过 window.open () 打开的窗口 。

我怎样才能让它不被作为弹出物堵住呢? 以后我又能和联署材料关闭它?

最佳回答

为了让Paypal的窗口打开而不被堵住, 我使用一个锁定目标 = “_blank ” 。

s s 选项, 但只要您在用户生成的事件( 如 < code> 点击 < / code > ) 处理器内为用户生成的事件调用 < code > 窗口。 打开 < / code >, 您可以打开弹出窗口。 所以只要您在链接上调用 < code > 点击 < / code> 处理器( 然后再关闭它) 。 现代弹出阻塞器( 过去几年来的任何内容), 块跳出器不是由用户事件触发的, 而是允许用户触发的 。

<p><a href="#" id="target">Click to open popup</a>; it will close automatically after five seconds.</p>
document.getElementById("target").addEventListener("click", () => {
    const wnd = window.open("https://stackoverflow.com");
    setTimeout(() => {
        wnd.close();
    }, 5000);
    return false;
});

(不幸的是, Stack 片段不允许您做 window.open .)

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签