我正在使用phonegap,遇到一个问题,当我从用户输入中按下“提交”按钮时,它一直在打开移动浏览器,我只想通过应用程序打开网站,而不是通过打开移动设备浏览器,有什么方法可以解决此问题?
脚本:
function displayCam()
{
if (document.getElementById('ipadd').value.match(/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/)) {
var ip = document.getElementById('ipadd');
var portz = document.getElementById('portz');
//document.getElementById('camView').innerHTML = ip.value;
var link = document.getElementById('camView').href="http://"+ip.value+":"+portz.value;
window.location.href =link;
return(true);
}
else{
alert("You have entered an invalid IP address or Something is missing!")
document.getElementById('ipadd').value = "";
document.getElementById('portz').value = "";
return (false);
}
代码:
<center>
<br>
<br>
<h2>Please Enter IP Address</h2>
<table>
<tr>
<th><label for="ipadd">Enter IP Address:</label></th>
</tr>
<tr>
<td><input type="text" id= 'ipadd' placeholder="xxx.xxx.xxx.xxx" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required" ></td>
</tr>
<tr>
<th><label for="portz">Enter Port:</label></th>
</tr>
<tr>
<td><input type='number' id='portz' pattern=".{1.4}" ></td>
</tr>
<tr>
<th><input type='button' onclick=' displayCam() ' value='Submit' required="required"></th>
</tr>
</table>
<div id="camView"> </div>
</center>