• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

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.

 
Greenhorn
Posts: 12
Android 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: 67503
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
I like tacos! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic