无法重定向到使用Javascript另一个页面 [英] Unable to Redirect to another page using Javascript
本文介绍了无法重定向到使用Javascript另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在HTML文件重定向使用Javascript我用这样的页面
window.location.href =http://www.google.com/
其工作罚款。但是当我的.aspx试过它不工作
下面是我的code。在此先感谢
<头=服务器>
<脚本类型=文/ JavaScript的>
功能PageRedirect(){
window.location.href =http://www.google.com/
}
< / SCRIPT>
< /头>
<身体GT;
<形式=服务器>
< ASP:按钮的ID =Button1的=服务器文本=按钮的OnClientClick =PageRedirect()/>
< /表及GT;
解决方案
试试这个:
< ASP:按钮的ID =Button1的=服务器文本=按钮的OnClientClick =PageRedirect();返回false;/>
In html file to redirect a page using Javascript i used like this
window.location.href = "http://www.google.com/";
Its working fine. But when i tried in .aspx it is not working Below is my code. Thanks in advance
<head runat="server">
<script type="text/javascript">
function PageRedirect() {
window.location.href = "http://www.google.com/";
}
</script>
</head>
<body>
<form runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="PageRedirect()"/>
</form>
解决方案
Try this:
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="PageRedirect(); return false;"/>
这篇关于无法重定向到使用Javascript另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文