eqiz
eqiz

Reputation: 1591

Website keeps causing a postback when clicking a # link

I think my issue is simple but I can't seem to figure out what I've done to screw things up but...

I can't do simple page postbacks without the page fully reloading for some unknown reason on my website..

EXAMPLE: I have an ANCHOR created called

<a id="multi" href="#"></a>

I can't call this link from within the page without it completely reloading the page. This is causing other serious issues such as me pulling up my website on my Android phone.. the Menu itself compresses completely fine, but when you click on the menu it actually forces the page to reload like its doing a postback or something when its not suppose to.

Same thing with my Chat Widget i have on my website on the bottom right corner... it uses javascript and has it pointed to "http://www.website.com/#" so that nothing is suppose to happen so it can load the window after its received a click, but something is causing my site to actually do a post and its trying to access that as an actual website.

Anyone have any idea what could be causing this? I've tried even completely deleting and removing all my javascript and CSS references and everything what am i missing?

Upvotes: 0

Views: 69

Answers (1)

Joseph
Joseph

Reputation: 119847

The # should only be making the page jump up. However, there'll be instances where:

Check if # is still on that link

There are times where some script removes the # and make that link point somewhere else. If you're on Chrome, you can inspect the link by right-clicking on it and inspecting it (other browsers should also have this too). Check if # is still the href.

Check for click handlers

There are also times when a handler is attached to links (I have a co-developer that did this once) and introduced too much magic to the page. Inspect the element and on the Elements tab of the inspector, there should be a tab called Event Listeners. Check for click handlers and inspect that. The harder thing to catch are delegated event handlers, so check for the ancestors as well.

Overlooking the obvious

  • You might have missed the #
  • You might be editing old code
  • You might be editing another file (always happens)
  • Clean the cache or debug in incognito or another browser profile which you can openly clear the cache.

Upvotes: 3

Related Questions