samedi 2 juillet 2016

How to make a javascript link behave like a html link?

I have to use Javascript for a link (at least I think so) in my openlayers map:

map.on("click", e => {
    map.forEachFeatureAtPixel(e.pixel, (feature) => {
        window.location.href = "/s/" + feature.getId();
        return true; // stop after first feature
    });
});

This works fine, but lacks some things:

  • There is no indication where the link is going to take me when hovering it.
  • Command-click does not open it in a new tab.

I thought about listening to hover and checking if command is pressed, but this seems error prone and only works for known system configurations.

Is there a way to make a javascript link work just like a HTML link?

Aucun commentaire:

Enregistrer un commentaire