I have an image on my webpage, when I click on it, it opens another website. This is the code: <a href=”https://www.pierrevin.com/ ” target=”_blank”><img align=”center” alt=”www.pierrevin.com Le site des étiquettes de vins” border=”0″ src=”../image/site_cognac-ton.jpg”></a>. I am trying to make it work via external javascript, but I can’t get it to work. I am very much a beginner. Here is what I thought should work:
The code in the BODY: <a href=”cognacton.js”><img align=”center” src=”../image/site_cognac-ton.jpg” alt=”www.cognac-ton Le site des étiquettes de cognac”></a>
The scriptline in the HEAD: <script src=”../css/js/cognacton.js”</script>
The text in cognacton.js: window.location.href=”https://www.pierrevin.com/”
When I click on the image ‘site_cognac-ton.jpg’ on my webpage, the result is a white page with the text of the js-file: window.location.href=”https://www.pierrevin.com/”. Why does it not open the www.pierrevin.com website?
Thanks in advance, Ton