我正在使用JavaScript构建跨平台应用。我想重定向到另一个页面(在不同的域中),但它无法正常工作。我试过了:
<html>
<head>
<script>
function redir() {
window.location.href = "http://www.example.com";
}
</script>
</head>
<body onload="redir()">
</body>
</html>
&#13;
它给了我一个空白页面。我尝试使用不同的代码,我尝试iframe
这样:
<html>
<head>
</head>
<body>
<iframe src="http://www.example.com" />
</body>
</html>
&#13;
但它没有再奏效。它给了我一个空白的iframe。有人能帮助我吗?
答案 0 :(得分:1)
function Redirect() {
window.location="https://www.tutorialspoint.com";
}
&#13;
<form>
<input type="button" value="Redirect Me" onclick="Redirect();" />
</form>
&#13;
答案 1 :(得分:-1)
<body onload="redir()"></body>