threeo Posted August 24, 2009 Share Posted August 24, 2009 i have an existing menu that uses DIVs where each drop-down menu item is an anchor that references a page. what i'd LIKE to do....is have one of my drop-down items fire a javascript confirmation....asking the user if they are sure they want to leave the site. i can get the anchor to fire the javascript just fine.....but it's the "href=" part that causes me problems. if the user clicks "no" (they don't want to leave the site....so....do nothing) they are getting redirected to some arbitrary page and i don't know why. i tried setting href="#" and href="" but get the same results. my javascript just says "if confirmation=="yes" then window.location="newpage" else "" (nothing) if i can't use an anchor.....is there a way to use a button but have it only show as plain text (don't want a button on my dropdown menu) Link to comment https://forums.phpfreaks.com/topic/171659-how-can-i-use-an-anchor-to-launch-a-snippit-of-javascript/ Share on other sites More sharing options...
RussellReal Posted August 24, 2009 Share Posted August 24, 2009 u dun really hafta use an anchor.. u could use javascript inside the href.. but if you want to use an anchor you'd use onclick="" inside the <a> tag.. but if you want to do like js in the href u just do <a href="javascript:code.to.do('when',CLICKED);">NO</a> Link to comment https://forums.phpfreaks.com/topic/171659-how-can-i-use-an-anchor-to-launch-a-snippit-of-javascript/#findComment-905161 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.