JavaScript document.location.href不工作..... [英] JavaScript document.location.href not working.....

查看:63
本文介绍了JavaScript document.location.href不工作.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Language =C#AutoEventWireup =trueCodeFile =Default.aspx.csInherits =_ Default%>



<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">



< html xmlns =http://www.w3.org/1999/xhtml>

< head runat =server >

< title>< / title>

< script type =text / javascriptlanguage =javascript>

函数confirmmsave()

{

var ans = confirm('你想保存吗?');

if(ans == true){

window.location.href ='login.aspx',true;

}

else {

返回false;

}

}





< ; / script>

< / head>

< body>

< form id =form1runat =server>

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" language="javascript">
function confirmsave()
{
var ans = confirm('Do u want to Save?');
if (ans == true) {
window.location.href = 'login.aspx', true;
}
else {
return false;
}
}


</script>
</head>
<body>
<form id="form1" runat="server">



< asp:Label ID =lbl1Text =runat = server>


< asp:FileUpload ID =FU1runat =server/>


< asp:Button ID =btnsubmitText =Uploadrunat =serveronClientClick =return confirmsave(); />


<asp:Label ID="lbl1" Text="" runat="server">

<asp:FileUpload ID="FU1" runat="server"/>

<asp:Button ID="btnsubmit" Text="Upload" runat="server" onClientClick="return confirmsave();" />



< / form>

< / body>

< ; / html>


</form>
</body>
</html>

推荐答案

请尝试以下方法。

Try the following.
window.location.href = 'login.aspx';



它假定此页面与调用者页面位于同一文件夹中。


It assumes that this page exist in the same folder as of the caller page.


function confirmsave()
{
var ans = confirm('Do u want to Save?');
if (ans == true) {document.location.href='login.aspx',true}
else {
return false;
}
}





工作......:)



works......:)


setTimeout(function(){document.location.href =page.html;},500);

它可以在所有浏览器中使用。
setTimeout(function(){document.location.href = "page.html;"},500);
it will work in all browser.


这篇关于JavaScript document.location.href不工作.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆