文章分类 Classification
强制设置主页
稿件来源: 阳光企业网站管理系统 撰稿作者: 太阳光 发表日期: 2011-11-05 阅读次数: 103 查看权限: 游客查看
强扭的瓜不甜,强制游客设置你的主页也不文明。但偶尔有人需要这种功能,所以我们简单研究一下!
设置本站为主页的链接方法:
<html> <head> <title>太阳光设计限定设置主页</title> </head> <script type="text/JavaScript" language="javascript"> var oldhref;var th; var homepag="http://127.0.0.1/"; function setHomepag(){ th=this; th.style.behavior='url(#default#homepage)'; if(!tt()){ th.setHomePage(homepag); if(!tt()){ alert("友情提示:您没有设置"+homepag+"为主页。"); oldhref = th.href; th.href = "javascript:"; setTimeout("th.href = oldhref"); } } } function tt(){ var a1 = document.getElementById("xzy"); a1.style.behavior='url(#default#homepage)'; return a1.isHomePage(homepag); } </script> <body> <a id="xzy"></a> <a onclick="this.setHomepag=setHomepag;this.setHomepag();" title="太阳光设计" href="http://127.0.0.1/"> <img src="http://www.qiannao.com/templates/default/images/space/download1.gif" width=16 /> 设为主页后转到http://127.0.0.1/</a> </body> </html>
缺点:因是明文标出连接地址,别人复制地址便可跳过限制!对小菜鸟有一定作用。所以必须在目标页做一些限制,如不能直接进入,必须由某个页面进入才能起到作用!
=================================美丽的分割线=============================
二级域名间强制设置主页:index.html
<html> <head> <title>太阳光设计</title> </head> <body> <iframe id="xzy" width="0" height="0" src="xzy.asp"></iframe> <a id="downlink1" onclick="this.setHomepage1=setHomepage1;this.setHomepage1();" title="太阳光设计" href="http://www.scscms.com"> <img src="http://www.qiannao.com/templates/default/images/space/download1.gif" width=16 /> 设为主页后转到http://www.scscms.com/</a> <script> //假如本文件放在www.scscms.com document.domain = "scscms.com"; //重点是这里 var oldhref; var a1; function setHomepage1(){ a1 = this; a1.style.behavior='url(#default#homepage)'; if(isHomepage1()){ }else{ a1.setHomePage('http://bbs.scscms.com/'); if(isHomepage1()){ }else{ alert("友情提示:您没有设置使用太阳光设计首页,无法使用VIP下载地址,请确定设置太阳光设计首页,或选择下面的普通下载地址。"); oldhref = a1.href; a1.href = "javascript:"; setTimeout("a1.href = oldhref"); } } } function isHomepage1(){ var ishomepage = document.getElementById('xzy').contentWindow.isHomepage(); return ishomepage; } </script> </body> </html>
xzy.asp
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> </head> <body> <a id="downlink1"></a> <script> document.domain = "xzy21.com"; function isHomepage(){ var a1 = document.getElementById("downlink1"); a1.style.behavior='url(#default#homepage)'; return a1.isHomePage('http://bbs.xzy21.com'); } </script> </body> </html>
=================================美丽的分割线=============================
不同域名间强制设置:index.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> </head> <body onload="send();"> <iframe id="xzy" width="0" height="0" src="http://www.xzy21.com/xzy.asp"></iframe> <a onclick="this.setHomepag=setHomepag;this.setHomepag(12);" title="太阳光设计" href="#"> <img src="http://www.qiannao.com/templates/default/images/space/download1.gif" width=16 />设为主页www.xzy21.com/</a> <script> var oldhref; var homepag="http://www.xzy21.com/"; function setHomepag(id){ this.style.behavior='url(#default#homepage)'; if(cook()){ this.href="down.asp?id="+id; }else{ alert("友情提示:下载前请先设置"+homepag+"\n为主页!本站只支持IE下载!"); this.setHomePage(homepag); send(); } } function send(){ document.getElementById("xzy").src=homepag+"xzy.asp?"+Math.random(); } function cook(){ var x=get_Cookie("xzy"); if (x=="ok"){ return true; }else{ return false; } } function get_Cookie(cookieName) { var cookieString = document.cookie; var start = cookieString.indexOf(cookieName + '='); if (start == -1) return null; start += cookieName.length + 1; var end = cookieString.indexOf(';', start); if (end == -1) return unescape(cookieString.substring(start)); return unescape(cookieString.substring(start, end)); } </script> </body> </html>
xzy.asp
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> </head> <body> <a id="xzy"></a> <script> var a1 = document.getElementById("xzy"); a1.style.behavior='url(#default#homepage)'; var t=a1.isHomePage('http://www.xzy21.com/'); if (t){ location.href="http://www.ftfree.cn/0/cookie.htm?ok"; }else{ location.href="http://www.ftfree.cn/0/cookie.htm?on"; } </script> </body> </html>
cookie.htm
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> </head> <body> <script type="text/javascript"> var url = window.location.href; var tt=url.split("?")[1]; if (tt==undefined||tt==""){ }else{ writeCookie("xzy",tt); } //==========写入Cookie function writeCookie(name, value) { exp = new Date(); exp.setTime(exp.getTime() + (86400 * 1000 * 30)); document.cookie = name + "=" + escape(value) + "; expires=" + exp.toUTCString() + "; path=/"; } </script> </body> </html>
这种方法主要是通过远程写cookies验证!
关键词: 主页,强制,设置主页 编辑时间: 2016-06-20 18:10:19
0
高兴0
支持0
搞笑0
不解0
谎言0
枪稿0
震惊0
无奈0
无聊0
反对0
愤怒
100%(3)
0%(0)
- 暂无评论
文章图片 article Pictrue
网友评论