0

我遇到了页面重定向问题。我有一段代码在执行的某个阶段假设将页面重定向到其他地址。但由于某种原因,它没有。

由于某些原因,我必须使用 javascript,这是我使用的代码:

window.location.assign("http://www.myaddress.com")

完整代码:

<head runat="server">
<title>try mail</title>

<script type="text/javascript">
    function openWin() {
        myWindow = window.open('myaddressgoeshere', '', 'width=600,height=400');
        myWindow.focus();
    }

<body>
<form id="form1" runat="server">
<div>
<table width="300px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> <img src="imagesNew/mail.jpg" width="75" height="52"/></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><div id="signin"></div></td>
</tr>
</table>

</div>
</form>

<script type="text/javascript" language="javascript">
    scope = ["wl.signin", "wl.basic", "wl.offline_access", "wl.emails", ],


function id(domId) {
    return document.getElementById(domId);
}

WL.Event.subscribe("auth.sessionChange",
    function (e) {
        if (e.session) {
            displayMe();
            authLogin();  
        }
        else {
            clearMe();
        }
    }
);

function authLogin(e) {
    if (e.status == 'connected') {
        WL.Event.unsubscribe("auth.login", authLogin);
        window.location.assign("http://www.hotmail.com");
        WinJS.Navigation.navigate('files.html');

    } 
}


</script>

4

4 回答 4

2

它需要在script标签中

<html>
<head>
<script>
function newPage()
  {
  window.location.assign("http://www.example.com")
  }
</script>
</head>
<body>

<input type="button" value="click" onclick="newPage()">

</body>
</html> 

http://jsfiddle.net/DpwnF/

于 2013-04-21T04:38:37.767 回答
2

您不必使用 javascript。您可以使用一个meta元素:

<meta http-equiv="refresh" content="0; url='http://www.myaddress.com/'">
于 2013-04-21T04:39:49.007 回答
1

document.location = "www.google.es"

于 2013-04-21T04:33:59.233 回答
1

您的 javascript 行没有错误。我认为你在其他地方有问题。请参考此链接

于 2013-04-21T04:41:28.997 回答