Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6096525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:56:15+00:00 2026-05-23T12:56:15+00:00

I’m sorry to ask such a simple question with such a small amount of

  • 0

I’m sorry to ask such a simple question with such a small amount of info, but I just can’t figure this out!

I have an ASP.NET page, into which I’ve added several plain-vanilla HTML buttons that are supposed to take the user to different pages. Here’s one example:

<button onclick="location.href='Default.aspx';">Go Back</button>

I would expect that when clicked, this button would redirect the browser to Default.aspx. Instead, it just seems to refresh the current page, keeping the URL intact.

The buttons are inside the page-wide ASP.NET <form> tag. The buttons do not submit the form. When I view the source code for the page in the browser, I do not see anything that should intercept a change in location (like an onunload event handler or anything like that). There are no other frames. There’s really nothing remarkable about this page at all.

I’ve tried using location=, self.location=, window.location=, and location.replace(). None of them work when executed from within the button’s onclick handler. I have tried in Firefox 5 and Chrome 10. The javascript does work when executed from the browser’s address bar like so: javascript: location.href='Default.aspx'; void(0);.

I’ve used Firebug’s javascript debugger to try to trace what happens when I click the button, and I haven’t seen anything unusual. I don’t see any event-intercepting code or other issues. There are no error logged in the error console.

It seems to me that I’ve used script like the before and it’s always worked just fine. Why isn’t it working now? Some code created by ASP.NET that I don’t know about? Is onclick not functional from within a <button>? Is this some JS security oddity that both Chrome and Firefox share?

Please help, this is driving me crazy!! Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:56:15+00:00Added an answer on May 23, 2026 at 12:56 pm

    Just add return false; like this:

    <button onclick="location.href='Default.aspx';return false;">Go Back</button>

    to stop the button submitting the form to itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.