I’m not sure how to do a pop-up that warns when you are clicking on external links, using javascript.
I figured that it would be handy to put a class on my external links as well, but I’m not quite sure it’s done correct as it is now either. This is the HTML I’m using at the moment:
<div id="commercial-container">
<a href="http://www.link1.com" class="external" target="_blank"> <img src="picture1.jpg" /> </a>
<a href="http://www.link2.com" class="external" target="_blank"> <img src="pciture2.jpg" /> </a>
<a href="http://www.link3.com" class="external" target="_blank"> <img src="picture3.jpg" /> </a>
<a href="http://www.link4.com" class="external" target="_blank"> <img src="picture4" /> </a>
</div>
I’m very new to javascript and very unsure on how to solve my problems. The pretty much only thing I figured out so far is that I will have to use window.onbeforeload but I have no clue on how to figure out how to write the function I need.
I want to keep my javascript in a separated .js document instead of in the HTML as well.
Call the confirm() function from the onClick attribute. This function returns true if the user clicks OK, which will open the link, otherwise it will return false.
Hope this helps.