如何在新窗口中打开链接

如何在新窗口中打开链接

本文介绍了如何在新窗口中打开链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  if(isset($ _ POST ['download'])){ 
...
}

用户点击提交按钮下载。



我尝试了document.location,但它在同一个标​​签中打开了一个链接,并且window.open要求浏览器应该启用弹出窗口,这可能会令人讨厌(在其他浏览器中也可能), target =_ blank会在新窗口中打开链接,而不是在新标签页中。



有什么我可以用来在新选项卡中正常打开一个窗口,比如< a href =>< / a> / code>?

解决方案

所有现代浏览器现在都包含选项卡功能。 $ b

尝试window.open(),浏览器将自动根据其配置完成任务。不同的浏览器会以不同的方式处理target =_ blank.Mozilla在新选项卡中打开,而chrome不打开。这不取决于您。 / p>

I need to open a new link automatically inside

if(isset($_POST['download'])) {
...
}

after user clicks on submit button download.

I tried document.location, but it opens a link in the same tab, and window.open requires that the browser should have pop-ups enabled, which can be annoying to users, plus in Chrome (may be also in some other browsers), target="_blank" opens a link in new window, not in a new tab.

Is there anything I can use to open a window normally in a new tab, like with <a href=""></a>?

解决方案

All modern browser now contain tab functionality.

Try window.open(), browser will automatically will do task as per its configuration.Different browser treat target="_blank" differently.Mozilla open in new tab while chrome not.It is not up to you.

这篇关于如何在新窗口中打开链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 15:20