调用localhost或hostname时的IE行为不同

时间:2015-03-11 10:50:33

标签: html forms internet-explorer

我有一个由websphere上的servlet生成的简单html页面。

<!DOCTYPE html>
<html>
<head>
<title>Server Management</title>
<meta http-equiv='refresh' content='3;URL="console"' />
<script> 
function setVal(command, i){
var elmnt = document.getElementById('myvalue')
elmnt.value = command + '-' + i;
}
</script>
</head>
<body>
<form action='console'>
  <button type='submit' onclick='setVal("stop", this.value)' name='stop' value='0'>Stop</button>
  <button type='submit' onclick='setVal("start", this.value)' name='start' value='0'>Start</button>
  <button type='submit' onclick='setVal("status", this.value)' name='status' value='0'>Status</button>
  <div style='display:inline'>Server 3 is <div style='display:inline;color:green'>UP</div> </div>
  <br/>
  <input  type='hidden' name='myvalue' id='myvalue'  value='bla'/>
</form>
</body>
</html>

问题是,当我调用localhost(或127.0.0.1)上传页面并按预期工作时,会发送正确的值

http://localhost:9081/MyApp/MyAction?status=0&myvalue=status-0

但是当我使用主机名(或IP)而不是localhost时,会发送元素的innerHTML而不是它的值,这当然会导致错误。

http://myhostname:9081/MyApp/MyAction?status=Status&myvalue=status-Status

我该怎么办?

1 个答案:

答案 0 :(得分:0)

所有关于IE版本......打开竞争模式解决了这个问题。

更好的解决方案是添加

<meta http-equiv="X-UA-Compatible" content="IE=8" />

到HTML。

感谢Microsoft为您提供的优秀应用