我正在尝试使用 jquery 打开新选项卡。但是,它不适用于 safari 或 Mac。
我的代码:
<script>
$(document).ready(function(){
$.ajax({
type: 'post',
dataType: 'html',
url:'http://localhost/test/remoteContent.html',
async: false,
success:function(data){
window.open("http:google.com",'_blank');
}
})
});
</script>
Run Code Online (Sandbox Code Playgroud)
我已经找到了替代解决方案。ajax响应后创建锚标记元素并触发点击事件
var a = document.createElement('a');
a.href = 'https://google.com';
a.setAttribute('target', '_blank');
a.click();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4812 次 |
| 最近记录: |