/    Sign up×
Community /Pin to ProfileBookmark

i would need a feature, when a user closes out of the site they are prompted to bookmark the site. if they have choosen to bookmark the site in the past they will not prompted for the bookmark.

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@felgallOct 07.2005 — Javascript is not able to access anything outside of the web page. It is therefore unable to see if a bookmark already exists. Javascript is also unable to generate bookmarks automatically, only JScript is able to do that (IE only).

Also when someone closes their browser down there would be insufficient time for such a script to run in any case.
Copy linkTweet thisAlerts:
@jmaresca2005authorOct 10.2005 — ah! the browser closing part of your reply makes absolute sense.
Copy linkTweet thisAlerts:
@felgallOct 10.2005 — On my page http://javascript.about.com/library/blfav.htm I have a script that will add a bookmark link to the page in IE and instructions on how to bookmark in Mozilla/Firefox/Netscape and Opera.
Copy linkTweet thisAlerts:
@jmaresca2005authorOct 10.2005 — thanks but i am already able to write a bookmark script in javascript, trying to figure out that extra functionality was the real task. thanks again ?
Copy linkTweet thisAlerts:
@konithomimoOct 10.2005 — Below is a simple code that will bring up the bookmark window in IE, and will alert the user to press ctrl + c to bookmark the site in netScape. At the end of the code you can change the value of 'renewal' to however many days you want it to be before the user is asked to bookmark your site again.

<i>
</i>&lt;script language="JavaScript1.2"&gt;
&lt;!--

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i &lt; clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc &gt; 2) ? argv[2] : null;
var path = (argc &gt; 3) ? argv[3] : null;
var domain = (argc &gt; 4) ? argv[4] : null;
var secure = (argc &gt; 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

var url = "http://www.javascript-page.com";
var title = "Nic's JavaScript Page";

if (GetCookie("bmark") == null) {

if (document.all) {
window.external.AddFavorite (url,title);
}

if (document.layers) {
bktext = open("", "displayWindow", "width=200,height=100,status=no,toolbar=no,menubar=no");

bktext.document.open();
bktext.document.write("&lt;html&gt;&lt;body bgcolor='white' text='black'&gt;"
+"Please Bookmark this Page. "
+"Press CTRL+C after closing.&lt;br&gt;&lt;br&gt;"
+"&lt;a href='javascript:self.close();'&gt;Close this window&lt;/a&gt;");
bktext.document.write("&lt;/font&gt;&lt;/body&gt;&lt;/html&gt;");
bktext.document.close() ;
}

var renewal = 30; //once a user has bookmarked your page they will not be asked to for another 30 days.
var exdate = new Date ();
exdate.setTime(exdate.getTime() + (renewal*24*60*60*1000));
SetCookie('bmark','book',exdate);
}

//--&gt;
&lt;/script&gt;
Copy linkTweet thisAlerts:
@jmaresca2005authorOct 11.2005 — very nice
Copy linkTweet thisAlerts:
@konithomimoOct 11.2005 — I hope it helped with what you wanted. But yes, nothing can help after the browser has closed.
×

Success!

Help @jmaresca2005 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...