【发布时间】:2016-12-16 01:31:16
【问题描述】:
我有一个表格。在这种形式中,有一个输入区域。当用户选择输入时,他们将被带到三个位置之一,具体取决于他们使用的设备。 android - google play 商店,iphone - iTunes 商店,桌面 - iTunes 网络浏览器。我能够检索 iphone 和桌面状态,但是 Android 似乎不适用于具有操作属性的表单标记。链接工作正常。不确定是什么问题。摘要——当我点击输入按钮时,什么也没有发生,没有弹出窗口,我的 android 上什么也没有。此外,当我将 http://www.google.com 的 url 放入表单的 action 属性中时,它可以正常工作。中间发生了一些事情。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name='viewport' content='initial-scale=1'>
</head>
<body>
<div class='main'>
<br/>
<br/>
<br/>
<form id="store-link" >
<input type='submit' value='Download'/>
</form>
<br/>
<br/>
<br/>
</div>
<div class='footer'>
<p>footer</p>
</div>
</body>
<script>
var a = document.getElementById('store-link');
if (navigator.userAgent.match(/Android/i)) {
a.action = 'http://www.google.com';
}
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))){
a.action = 'itms://itunes.apple.com/us/app/peanuts-storygif-christmas/id1181016912?mt=8';
}
else {
a.action = 'https://itunes.apple.com/us/app/peanuts-storygif-christmas/id1181016912?mt=8';
}
</script>
</html>
【问题讨论】:
-
好像不能修改提交的action属性,possible duplicate
标签: javascript html