Thursday, July 04, 2024

link from div to open in new window

We wanted a "click here" image link for one of our websites, but the image was actually a background in CSS and not a simple img html tag. So, basically we needed to make the entire div into a clickable link. Following these,

https://stackoverflow.com/questions/7185044/change-the-mouse-cursor-on-mouse-over-to-anchor-like-style

https://stackoverflow.com/questions/5141910/javascript-location-href-to-open-in-new-window-tab

https://stackoverflow.com/questions/8524470/click-anywhere-on-div-instead-of-directly-on-link

what we used was something like this:

<div class="our-class-name" style="cursor: pointer" onclick="window.open('ourpage.html', '_blank');">

No comments:

Post a Comment