[英]Page redirection not working for Android device
我正在使用Captive Portal。 因此,當用戶加入Internet登錄頁面時就會出現。 一旦用戶輸入憑據,它將顯示成功頁面。因此,成功頁面之前已經加載。我的工作是成功頁面加載,我需要重定向我們的網址。 所以我隱藏了所有設計和負載,我寫了腳本進行重定向。 它可以在ios和Windows上運行,但不能在Android設備上運行。它只是加載頁面2秒鍾,然后自動消失了。
<body onload="redirect()">
<div>
<iframe name="iFrameName" src="" frameBorder="0" >
</iframe>
</div>
<script>
function redirect()
{
// if(navigator.userAgent.match(/Android/i))
// window.open("http://xxxx.xxx/",'_system')
// else
// window.location.replace("http://xxxx.xxx/");
var site = "http://xxxx.xxx/";
document.getElementsByName('iFrameName')[0].src = site;
}
</script>
</body>
我嘗試了快速的注釋代碼,但沒有成功。請幫忙嗎?
默認情況下,WebView中禁用了JavaScript。 您需要打開它:
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
我希望您像這樣將互聯網許可授予android mainfest文件。
<uses-permission android:name="android.permission.INTERNET" />
試試這個代碼。
mWebView = (WebView) findViewById(R.id.activity_main_webview);
myWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("https://www.bluehost.com/track/businessplan/");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.