You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
3.0 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//begin --判断是否弹出过收藏夹,如弹出过(不管添没添加)都不再弹出收藏夹
function setCookie(name,value,days)
{
var exp=new Date();
exp.setTime(exp.getTime() + days*24*60*60*1000);
var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString();
}
function getCookie(name)
{
var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr!=null)
{
return unescape(arr[2]);
return null;
}
}
function delCookie(name)
{
var exp=new Date();
exp.setTime(exp.getTime()-1);
var cval=getCookie(name);
if(cval!=null)
{
document.cookie=name+"="+cval+";expires="+exp.toGMTString();
}
}
//End
//弹出收藏夹 begin
//isclick = false;
function bookmark() {
if (getCookie("bookmark") != "yes") {
setCookie("bookmark", "yes", 1); //记录已经弹出过收藏夹(不管添没添加)都记录
var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL';
try {
if (document.all) { //IE类浏览器
try {
window.external.toString(); //360浏览器不支持window.external无法收藏
window.alert("国内开发的360浏览器等不支持主动加入收藏。\n您可以尝试通过浏览器菜单栏 或快捷键 ctrl+D 试试。");
}
catch (e) {
try {
window.external.addFavorite(window.location, document.title);
}
catch (e) {
try {
window.external.addToFavoritesBar(window.location, document.title); //IE8
}
catch (e) {
alert('添加收藏失败,您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~');
}
}
}
}
else if (window.sidebar) { //firfox等浏览器
window.sidebar.addPanel(document.title, window.location, "");
}
else {
alert('您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~');
}
}
catch (e) {
window.alert("因为IE浏览器存在bug添加收藏失败\n 解决办法:您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~ "); //\n 或者在开始菜单中的运行中输入“Regedit”打开注册表然后查找\n HKEY_CLASSES_ROOT\\TypeLib\\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\\1.1\\0\\win32 \n将 C:\\WINDOWS\\system32\\shdocvw.dll 改为 C:\\WINDOWS\\system32\\ieframe.dll 后,再重新启动浏览器试试!");
}
}
}
document.onclick = function () {
bookmark();
// if (!isclick) {
// isclick = true;
// collect();
// }
}
//end