Html Safari的网页行为不同
以下html代码是一个简化版本,用于演示在ipad或iphone上与Safari配合使用时出现的问题Html Safari的网页行为不同,html,ios,safari,Html,Ios,Safari,以下html代码是一个简化版本,用于演示在ipad或iphone上与Safari配合使用时出现的问题 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta charset="utf-8" /> <title>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Testing</title>
<script type="text/javascript">
function getstuff()
{
document.dataentry.tandc.blur();
<!-- Show the Continue button now -->
document.getElementById("open").hidden="";
ff.style.display='block';
document.dataentry.sb.focus();
}
</script>
</head>
<body>
<div class="span8">
<div class="row">
<div class="box">
<h3>Sign Up To Access Wi-Fi</h3>
<!-- Not going via Facebook -->
<form name="dataentry" action="http://www.cavreporter.com.au:90/Portal/DoNothing.php" method="post">
<div class="field" align="left">
<span><input type="text" name="fn" placeholder="Name" /></span>
</div>
<div class="field" align="left">
<span>
<input type="email" name="em" id="txtEmail" placeholder="Email Address" />
</span>
</div>
<div class="field" align="left">
<span>Subscribe: <input type="checkbox" name="sb" /></span>
<label>
<h5>By ticking subscribe you agree to receive information</h5>
</label>
<input name="tc" type="hidden" />
<button class="button" style="text-decoration: underline;" name="tandc" type="submit" onclick="getstuff()">Sign Up</button>
</div>
</form>
</div>
</div>
</div>
<!-- This is the "Enter" button for "Open" networks. -->
<div style="display:none;" id="ff">
<!-- This is the "Enter" button for "Open" networks. -->
<div class="span8">
<div class="row">
<div class="box">
<strong>By clicking Continue, you agree.</strong>
<form action="$authaction" method="get">
<input name="tok" type="hidden" value="$tok" />
<input name="redir" type="hidden" value="$redir" />
<button class="button" style="text-decoration: underline;" id="open" hidden="hidden" type="submit">Continue</button>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
代码显示两个文本字段和一个按钮,而另一个按钮目前对用户隐藏。在文本字段中输入信息后,单击按钮,此时会出现另一个按钮。在Safari设备上使用此按钮时,第二个按钮会按预期显示,然后几乎立即使用action语句中php例程的地址加载一个新页面。使用其他浏览器时,页面不会加载,按钮会按预期显示
我只是滥用了HTML标准,还是Safari需要更多的东西,因为我不想让它加载页面
这方面的一个例子可以在www.cavreporter.com.au:90/fu.html上找到,因为您的按钮有type=submit,所以表单正在发布
因此,您只需按如下方式更改按钮:
<button class="button" style="text-decoration: underline;" name="tandc" type="button">Sign Up</button>
其中type=button而不是type=submit
在你的第一张表格上也能看到提交活动,这将是一个很好的形式,以防止意外提交。谢谢Vinchi。我做了建议的更改,但这并不能解决问题。当我在ipad或iphone上进行测试时,仍在加载页面。@HarryWombat更新了答案,只需更改按钮元素类型。部分问题还与ipad和iphone在发现开放Wi-Fi网络时喜欢使用的捕获式门户程序有关。如果连接到Wi-Fi网络而不是Safari,ipad/iphone将使用不支持我尝试使用的html的混合浏览器。通过删除action&method语句并在函数中使用xmlhttpRequest指令,修改了代码以适应Capture portal browser的工作方式。结果对我来说是一样的,它适用于ipad/iphone