admin管理员组

文章数量:1361302

In html file to redirect a page using Javascript i used like this

window.location.href = "/";

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 = "/";
   }
 </script>
</head>
<body>
<form runat="server">
  <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="PageRedirect()"/>
  </form>

In html file to redirect a page using Javascript i used like this

window.location.href = "http://www.google./";

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./";
   }
 </script>
</head>
<body>
<form runat="server">
  <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="PageRedirect()"/>
  </form>
Share Improve this question edited Mar 6, 2013 at 11:07 Jagadesh asked Mar 6, 2013 at 11:02 JagadeshJagadesh 3741 gold badge6 silver badges16 bronze badges 2
  • Its working is IE for me , but not in chrome. – Prashant Mehta Commented Mar 6, 2013 at 11:11
  • Its not working for me in IE and Chrome but below change is working fine – Jagadesh Commented Mar 6, 2013 at 11:18
Add a ment  | 

1 Answer 1

Reset to default 8

Try this:

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

本文标签: aspnetUnable to Redirect to another page using JavascriptStack Overflow