javascript Redirect wont work with "image" button in ASP.NET

asp.net , java , javascript Romania
  • 10 years ago

    I've got this Javascript fuction below

    function doit()

    {

    window.location.href = 'http://www.msn.com';

    }

    Then I got this simple HTLM code in my Test.aspx page

    <input type="button" value="Redirect" onclick="doit();" />

    <input type="image" src="PrettyGraphic.gif" onclick="doit();" />

    Problem is the regular button (type=button) works fine (the page gets redirected okay) but the image button does NOT. And this problem happens only when its an aspx file. With a regular .htm file, everuthing works great.

    Any help would be greatly appreaciated

     

     

     

  • 10 years ago

    Hi,

    try the below one...

    function doit()

    {
        window.location.href = 'http://www.msn.com';
        return false;
    }

     

     <input type="image" src="PrettyGraphic.gif" onclick="return doit();" />

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves” - Alan Kay