如何open一个新tab页面
生活随笔
收集整理的這篇文章主要介紹了
如何open一个新tab页面
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
打開新tab頁的兩種方式
1 a標簽
function openwin(url) {var a = document.createElement("a");a.setAttribute("href", url);a.setAttribute("target", "_blank");a.setAttribute("id", "camnpr");document.body.appendChild(a);a.click();}2 window.open
window.open('https://sandbox.ebanx.com/print/?hash=59ad5dd18a6d5ba0e24327c2ba92a730115a80bd58b3baa5', '_blank')有3種情況會需要打開新tab頁,
- 人為點擊一個按鈕,在事件里我們可以打開新的tab頁,window。open()
- 用戶直接點擊a標簽打開新tab頁
- 用戶觸法的ajax回調,在回調事件里才能拿到新的需要跳轉的tab頁的url,此時以上方法打開新頁面時候回被chrome等游覽器默認攔截
解決方案:
function click() {var newWin = window.open('loadingurl');$.ajax({url: url,type: "post",data: payParams,dataType: 'json',success: function (response) {newWin.location = response.data.url}})}就是在點擊的時候 先打開一個默認的loading頁面 然后在等url回來后在賦值給location
以上
轉載于:https://www.cnblogs.com/WhiteHorseIsNotHorse/p/9076759.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的如何open一个新tab页面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mybatis 一对多_Mybatis
- 下一篇: 方形物体绕中心旋转的扭力_三维旋转