• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

onclick="location.href=#" doesn't work anymore?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In the following example, I want to summon #b if #a is missing and vice versa. How can I do that using same anchor tag? The code is for the same page. The following code doesn't work anymore.

 
Bartender
Posts: 217
7
Android Python Oracle Postgres Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this and result is that both the onclick and href are "executed": just have a look in your browsers history.  One step back you'll find thepage with  #b and two steps back the page before the click.

history.png
[Thumbnail for history.png]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's take a step back, and please explain how #a could be "missing". If this is a static HTML page, then the contents are well-known and there's no need for a fallback. If it's a generated page where #a is dynamically generated based upon a condition, that same condition can be used to correctly target the link. Rather than trying to trick HTML into doing something it wasn't designed for, let's take a look at the bigger picture and solve it in a conventional manner.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic