Unable to Redirect to another page using Javascript

核能气质少年 提交于 2020-01-03 10:32:47

问题


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>

回答1:


Try this:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="PageRedirect(); return false;"/>


来源:https://stackoverflow.com/questions/15245572/unable-to-redirect-to-another-page-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!