简体   繁体   English

页面重定向不适用于Android设备

[英]Page redirection not working for Android device

I am working on Captive Portal. 我正在使用Captive Portal。 So when user join internet login page will come. 因此,当用户加入Internet登录页面时就会出现。 once user entered credential it will show success page.So success page was loading before.My work was on success page load i need to redirect our url. 一旦用户输入凭据,它将显示成功页面。因此,成功页面之前已经加载。我的工作是成功页面加载,我需要重定向我们的网址。 So i hide all designs and body on load i wrote script for redirection. 所以我隐藏了所有设计和负载,我写了脚本进行重定向。 It works in ios and windows but not working in Android device.It is just loading page for 2 seconds then disappearing automatically.I tried through iframe but it did not work. 它可以在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>

Commented code i tried fast, but it did not work.Any help please? 我尝试了快速的注释代码,但没有成功。请帮忙吗?

JavaScript is disabled in a WebView by default. 默认情况下,WebView中禁用了JavaScript。 You need to turn it on: 您需要打开它:

WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

I hope you give internet permission into android mainfest file like this way.. 我希望您像这样将互联网许可授予android mainfest文件。

<uses-permission android:name="android.permission.INTERNET" />

Try this code.. 试试这个代码。

   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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM