After the first stop, automatically prompts the collection of code

Source: Internet
Author: User
Tags code cookie cookies customer document domain function home page

Intermediary trading SEO diagnostic Taobao guest hosting technology hall

There are many novice online every day, many people do not know how to collect addresses. Only through the home page level one level link, this is a novice. But novice if found a good station, will often visit. Because he has not found better yet, naturally think your station is the best. How to let novice collect your station? Use good collection code is particularly important!

Currently, there are several ways for viewers to bookmark your website.

1, some people say that the link on the page, a little on the collection.

Oh, if he knows click, or see this link, it is estimated that it is not a novice. This usage is not suitable for beginners.

2, open the web page, or exit the web page, pop-up tips.

This point, I will not say anything, anyway, I am annoying such a website. Not recommended for use.

3, a popular method is to move the mouse to a location, automatically jump out of the collection.

However, there is one drawback to this approach. If this area is large, it will pop up repeatedly, harassing visitors and annoying people. If small, will not pop-up prompts, lost the role of tips collection.

According to the above, after consideration, thought of the use of cookies to control the collection.

The final effect:

The first time visitors visit the page, when the mouse moves to a designated location (for example, the bottom of the page), will automatically pop-up Favorites tips. Not every time you open or exit are pop-up prompts.

The next time you visit the page will no longer prompt, to prevent the collection later, open the page, continue to prompt collection, very annoying. Use cookies here. Unless cookies are cleared.

This approach effectively prompted the viewer favorites. Prevent your site from missing because you do not bookmark it or ignore it.

principle:

This method is to control the use of cookies appear in the page a div box, the first visit, there will be a box, add a collection of this div action. According to this principle, you can also extend the thinking, to make other effects.

Usage: The following code is saved as js, in any position on your page can be added. It is recommended to join the bottom of the page, this location is the viewer does not pay attention to the location, but also the mouse is very easy to trigger position. We can see the demo station, www.1meirong.cn pay attention to the black line at the bottom of the page, when the mouse moved to this position, automatically pop-up collection tips, and visit again, this black line will not be displayed, it will not Will prompt collection. Of course, you can change this div to something else, put it elsewhere in the page, or you can add other actions for extended use.

The following is the content of the code:
<! - Begin
var expDays = 7;

// Cookie code from The JavaScript Source
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i <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> 2)? argv [2]: null;
var path = (argc> 3)? argv [3]: null;
var domain = (argc> 4)? argv [4]: ​​null;
var secure = (argc> 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": "");
}
function DeleteCookie (name) {
var exp = new Date ();
exp.setTime (exp.getTime () - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires =" + exp.toGMTString ();
}
var exp = new Date ();
exp.setTime (exp.getTime () + (expDays * 24 * 60 * 60 * 1000));
function amt () {
var count = GetCookie ('count')
if (count == null) {
SetCookie ('count', '1')
return 1
}
else {
var newcount = parseInt (count) + 1;
DeleteCookie ('count')
SetCookie ('count', newcount, exp)
return count
}
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape (document.cookie.substring (offset, endstr));
}

function checkCount () {
var count = GetCookie ('count');
if (count == null) {
count = 1;
SetCookie ('count', count, exp);

if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt (navigator.appVersion)> =

4)) {
document.writeln ("<div onmouseover = \" window.external.addFavorite (\ 'http: \ / \ / www.1meirong.cn \', \ 'First Beauty Network - ; "style = \" background-color: # 000000; font-size: 3px; HEIGHT: 2px; \ "> <\ / div>");
}
else {
var msg = "!";
if (navigator.appName == "Netscape") msg ​​+ = "(CTRL-D)";
alert (msg);
}
}
else {
count ++;
SetCookie ('count', count, exp);
}
}
checkCount ();
// End ->

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.