window.open/window.close 在iOS上的坑 === :::warning 本篇為 [window.open/window.close 父子視窗開啟新頁面交互傳值](https://hackmd.io/@eating-coding/SyS7wAN-Y) 之後續,請先閱讀完,再到此篇繼續閱讀。 ::: 實作此篇 [window.open/window.close 父子視窗開啟新頁面交互傳值](https://hackmd.io/@eating-coding/SyS7wAN-Y) 後,發現在電腦和Android網頁上都可以正常運行,但在iOS上卻無法開啟新視窗,後來找到問題,原因是iOS瀏覽器對安全性保護的一些限制,封鎖了開啟新分頁的功能,且我把 ```window.open()``` 包在 ```promise``` 裡執行,因此無法開啟新視窗。 解決方法 --- 我們在開啟新視窗前,先開個空的視窗,再將要開啟的子視窗網址塞入。 ```javascript= // 開啟視窗 this.windowChild = window.open('','_blank','fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=auto,resizable=0'); // 塞入網址 this.windowChild.location = 'URL'; ``` 在iOS上就可以正常執行了 ###### tags: `iOS` `APP` `Safari` `前端開發筆記`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up