我有一个html页面:
<html>
<head>
<script type="text/javascript">
function myfunct()
{
window.location='test.html';
document.getElementById("message")="hello";
}
</script>
</head>
<body>
<input type="button" value="click" onclick="myfunct()"/>
</body>
</html>
测试.html:
<html><head></head>
<body>
<div id="message">Some text</div>
</body>
</html>
问题是window.location
工作正常,但 div 没有更新为“hello”。