I'm developing a bookmark/favourite incentive script and currently the user is awarded even if they click 'cancel' in the add-bookmark dialogue box.. Is there any way to catch some sort of call back result from the browser to see if the bookmark dialogue was confirmed or cancelled? Thanks for any help! Chuck
if(window.confirm("[I]sometext[/I]")) { //user clicked OK } else { //user clicked cancel } Code (markup):
Thanks for trying to help Rukbat, but I'm looking for a solution to know whether the user clicked OK or Cancel in the bookmark dialogue box.. Not a standard Ok/Cancel confirm() window.. Is there any way?
Yeah.. I have a simple bookmark function I use in a link.. ie: <a href="#" onclick="AddBookmark(); return false;">Bookmark us and earn 50 points!</a> Code (markup): The Bookmark() function currently awards points after the standard bookmark function has been carried out.. ie, the script opens the bookmark dialogue (similar to if they had pressed CTRL+D), and on completion of that dialogue, the script then awards 50 points to their account.. Code snippet: function AddBookmark(url,title) { if (window.sidebar){ // firefox window.sidebar.addPanel(title, url, ""); } else if(window.opera && window.print){ // opera var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); } else if(document.all){ // ie window.external.AddFavorite(url, title); } AwardPoints(50); } ... Code (markup): However, even if you CANCEL the bookmark dialogue, points are still awarded.. Because I haven't put the AwardPoints() function in any sort of 'if' statement.. What I'm looking for is a result I can retrieve from the bookmark dialogue or some sort of trigger to award the points, rather than just assuming they clicked OK in the bookmark dialogue. Chuck
From everything I can determine, the bookmark function doesn't return anything in any of the main browsers. It's not written to be used as an "if bookmark added" function.
Damn Ok nevermind.. It's a one-time function anyway so it can't be 'abused', but it would've been nice to be able to make sure they DID add the bookmark - but at the end of the day, if they wanted to falsify it, they could just delete the bookmark afterwards anyway Thanks for your efforts Rukbat!