Hi ALL, Is there a way or a function that can differentiate between normal links and popup. When pressed where a warning message with only show in case normal links are pressed and won't show if the popup link are pressed I am using this script, YAHOO.namespace("example.container"); function Warningfunction(e) { return confirm("ok to go?"); } function init() { links = document.getElementsByTagName("a"); for (var j = 0; j < links.length; j++){ var oElementl = links.item(j); YAHOO.util.Event.addListener(oElementl, "click",Warnfunction); } } YAHOO.util.Event.onDOMReady(init); But this is going to grab all elements with <a> tag i.e. popup and normal links. the Warnfunction is a function that gives the Warning Message I'll be more than grateful for any help and suggestion
Depends on how you're calling the popup. Normal popups called with window.open can be distinguished by the following: YAHOO.namespace("example.container"); function Warningfunction(e) { return confirm("ok to go?"); } function init() { links = document.getElementsByTagName("a"); for (var j = 0; j < links.length; j++){ var oElementl = links.item(j); if(oElementl.href.substr(0, 10).toLowerCase()!="javascript") YAHOO.util.Event.addListener(oElementl, "click",Warnfunction); } } YAHOO.util.Event.onDOMReady(init); HTML: This will add a click event to links that don't look like this: <a href="javasript:window.open()">anchor tag</a> HTML: Is this what you want?
What about links that look the way they should? <a href="#" onclick="window.open();return false">anchor tag</a> Code (markup):
YAHOO.namespace("example.container"); function Warningfunction(e){ return confirm("ok to go?"); } function init() { links = document.getElementsByTagName("a"); for (var j = 0; j < links.length; j++){ var oElementl = links.item(j); if(!oElementl.onclick) YAHOO.util.Event.addListener(oElementl, "click", Warningfunction); } } YAHOO.util.Event.onDOMReady(init); HTML: Tested and working with the latest Yahoo libraries.