帝国CMS如何设置屏蔽页代码
情景描述:当我们不想让用户直接看到真正的内容时候,但又不让蜘蛛发觉,以致快照更改,所以需要用到屏蔽页,这样既能兼顾用户浏览的需求,也能兼顾到蜘蛛,不至于快照被篡改的情况。
步骤:
1.制作一个txt文本文件,填充假页面代码,(注意,保存文件格式一定是txt文档)如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>闇栨邯闆呬俊鎭綉</title> <style> /* 鍏ㄥ眬鏍峰紡 */ body, ul, ol, li, p, h1, h2, h3, h4, h5, h6, form, fieldset, table, td, img, div { margin: 0; padding: 0; border: 0; } body { background: #fff; color: #666; font-size: 16px; font-family: SourceHanSansCN-Regular; } i, em { font-style: normal; } ul, ol { list-style-type: none; } select, input, img, select { vertical-align: middle; } a { text-decoration: none; } a:hover, a:active, a:focus { color: #333; /* text-decoration: underline; */ } /* 娓呴櫎娴姩 */ .clearfix:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; } .clearfix { zoom: 1; } .fl { float: left; } .fr { float: right; } /* 鍗曡婧㈠嚭鐪佺暐鍙� */ .one-txt-cut { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .customBody { background: #f5f6f8; } .customHead { width: 100%; background-color: #ffffff; } .customHead .customNav { width: 1140px; height: 158px; margin: 0 auto; display: flex; align-items: center; justify-content: center; } .customHead .customNav h1 { font-size: 60px; color: #333; } .customHead .customNav .logo { width: 244px; height: 47px; } .customMain { margin: 30px auto 0 auto; width: 1140px; } .customMain .leftBox { width: 749px; background-color: #ffffff; border: solid 1px #ededed; box-sizing: border-box; } .customMain .leftBox .headline { height: 152px; position: relative; padding: 0 57px; overflow: hidden; box-sizing: border-box; border-bottom: 1px solid #ededed; } .customMain .leftBox .headline .sign { position: absolute; top: 0; right: 60px; } .customMain .leftBox .headline h1 { font-size: 22px; color: #333333; line-height: 1; margin: 56px 0 17px 0px; margin-bottom: 17px; } .customMain .leftBox .headline .message { font-size: 12px; line-height: 1; color: #666666; width: 357px; display: flex; align-items: center; justify-content: space-between; } .customMain .leftBox .content { padding: 24px 60px 85px 60px; box-sizing: border-box; } .customMain .leftBox .content .banner { width: 627px; height: 409px; margin-bottom: 28px; } .customMain .leftBox .content p { font-size: 14px; line-height: 30px; letter-spacing: 1px; color: #333333; } .customMain .rightBox { width: 360px; } .customMain .rightBox .box { margin-bottom: 24px; background-color: #ffffff; border: solid 1px #ededed; box-sizing: border-box; } .customMain .rightBox .box .title { padding: 0 22px; height: 65px; font-size: 22px; letter-spacing: 0px; color: #333333; box-sizing: border-box; border-bottom: solid 1px #ededed; display: flex; align-items: center; justify-self: center; } .customMain .rightBox .box .title i { width: 4px; height: 26px; background-color: #01a751; border-radius: 2px; margin-right: 12px; } .customMain .rightBox .box .imageText { padding: 24px 27px 38px 27px; } .customMain .rightBox .box .imageText img { width: 304px; height: 304px; margin-bottom: 35px; } .customMain .rightBox .box .imageText p { font-size: 14px; line-height: 27px; letter-spacing: 0px; color: #666666; } .customMain .rightBox .box .listText { width: 300px; margin: 27px auto 25px auto; } .customMain .rightBox .box .listText .item { padding-bottom: 25px; box-sizing: border-box; } .customMain .rightBox .box .listText .item p { font-size: 14px; line-height: 27px; letter-spacing: 0px; color: #333333; } .customMain .rightBox .box .listText .item em { display: block; font-size: 14px; line-height: 27px; letter-spacing: 0px; color: #666666; text-align: right; } /* 搴曢儴footer */ .customFooter { text-align: center; padding: 65px 0 43px 0; line-height: 26px; box-sizing: border-box; font-size: 14px; color: #999999; } </style> </head> <body class="customBody" onselectstart="return false;" oncontextmenu="return false;"> <div class="customHead"> <div class="customNav"> <h1>闇栨邯闆呬俊鎭綉</h1> </div> </div> <div class="customMain clearfix"> <!-- 宸︿晶鍐呭 --> <div class="leftBox fl"> <div class="headline"> <img class="sign" src="http://www.gl766.com/images/ico.png" alt=""> <h1>闇栨邯闆呬俊鎭綉</h1> <p class="message"> <span>鏃ユ湡锛�2022/05/01 15:55</span> <span>鏉ユ簮锛氶湒婧泤</span> <span>浜烘皵锛�8652</span> </p> </div> <div class="content"> <img class="banner" src="https://www.cqgzfs.com/pic1.jpg" alt=""> <p>璇村疄璇濓紝鎬绘湁璁稿鐨勮瘽瑕佽锛屽洜涓烘垜鏃跺埢琚劅鍔ㄧ潃锛岀湅鐫€鎴戜滑鐨勫ぇ瀹跺涵锛屾垜鐪熺殑寰堟鎱帮紝涔熻褰撴椂鍦ㄥ仛鍑洪€夋嫨鏃讹紝鎴戞崯澶变竴浜涗笢瑗匡紝鍙槸鍥炲ご鎯虫兂锛屾垜鐪熺殑寰堝垢杩愶紝鎴戜篃寰堟劅鍔ㄨ嚜宸卞仛鍑轰箟鏃犲弽椤剧殑鎶夋嫨锛屽洜涓哄湪杩欎釜澶у搴噷锛屾垜寰楀埌浜嗕箣鍓嶆垜娌℃湁鎯冲埌鐨勪笢瑗匡紝淇′换銆佹弧瓒炽€佹劅鍔紝杩樻湁鎴戜滑灏嗚瀹炵幇鐨勫叡鍚岀殑鐩爣銆傚浜庢垜鐜板湪鐨勮繖涓搴紝鎴戝彧鏈夌湡姝g殑鍏ㄥ姏浠ヨ荡锛屾墠瀵瑰緱璧锋垜鑷繁锛屽寰楄捣鎴戠殑杩欎簺瀹朵汉銆傜湅鐫€鎴戠殑瀹跺涵浜轰竵鍏存椇锛岃€屼笖澶у鍥㈢粨涓€鑷达紝鍔姏鏈濆墠鐨勬牱瀛愶紝鎴戞墦蹇冪溂閲岄珮鍏达紝璇村疄璇濓紝鍜岃档鎬荤殑鍏崇郴涓嶄絾鏄笂涓嬬骇锛屾洿鏄濡癸紝鍦ㄥス鐨勮韩涓婏紝鎴戝鍒颁簡寰堝浜嗕笢瑗匡紝鎴戠湅鍒颁簡鍧氬己銆侀瓌鍔涖€佸拰濂归偅鐙竴鏃犱簩鐨勯瓍鍔涳紝鍦ㄥス閭i噷锛屾垜浠病鏈夐敊璇紝鏈夌殑鍙槸涓嶆柇鐨勬彁鍗囷紝娌℃湁浠讳綍涓嶄俊浠伙紝鍙湁涓嶆柇鐨勯紦鍔憋紝瀵逛簬鎴戜滑宸ヤ綔涓殑涓嶈冻锛屽ス鎬绘槸寰堝阀濡欏府鎴戜滑鍥為伩锛屽苟涓斾娇寰楁垜浠笅娆′笉鍐嶇姱鍚屾牱鐨勯敊锛屽綋鎴戜滑宸ヤ綔閬囧埌鍥伴毦鏃讹紝濂圭粰鎴戜滑鏇村ソ銆佹洿蹇殑瑙e喅鍔炴硶锛屾墍鏈夌殑闂鍒颁簡濂归偅閲岋紝灏卞彉寰椾笉鏄棶棰橈紝鑰屾槸鎴戜滑鍚戞洿楂樼洰鏍囪繄杩涚殑鍙伴樁锛岃鎴戜滑鍦ㄥ伐浣滅殑杩囩▼涓紝涓嶆柇鍦板厖婊′俊蹇冿紝涓嶆柇鍦版垚闀匡紝骞朵笖涔熶笉鏂殑鑷俊锛屾洿鏄笉鏂殑鎻愬崌銆傚啀鐪嬫垜浠煶鎬伙紝铏界劧浠栨槸涓€浣嶇敺澹紝浣嗘槸鎴戜滑濡傛灉纰板埌涓€浜涗笉鐞嗚В鐨勪簨鎯咃紝鎴戜滑杩樻槸寰堟効鎰忓拰浠栦氦娴侊紝鍜屼粬浜ゆ祦瀹屼箣鍚庯紝灏辨劅瑙夌溂鍓嶄竴鐗囬槼鍏夌伩鐑傦紝浠栨€绘槸鎶婃墍鏈夌殑浜嬫儏鐪嬪緱寰堥€忥紝璇村緱寰堟槑鐧斤紝鎬绘槸缁欐垜浠帿澶х殑榧撳姳鍜屾敮鎸侊紝璁╂垜浠瘡涓€涓汉鐨勫績鐞嗗厖婊″笇鏈涳紝鑰屼笖涔熻鎴戜滑寰堟竻妤氾紝鎴戜滑鐨勭洰鏍囪鎬庢牱鍋氭墠鑳藉寰椾互瀹炵幇锛屽湪鎴戜滑鐨勮韩涓婏紝鎬绘槸鑳藉寰楀埌璧垫€诲拰鐭虫€讳粬浠殑鏈€澶ф敮鎸佷笌甯姪锛岃瀹炶瘽锛屽湪浠栦滑閭i噷锛屾垜鐪熺殑搴旇鏄兘鍔涙垚闀胯繃绋嬩腑鏈€澶х殑鍙楃泭鑰呫€傛垜鐜板湪杩樻湁涓や釜鏈€濂界殑鍚堜綔浼欎即锛屼篃鏄渶濂界殑濮愬锛屽氨鏄瘺鍜屽垬锛屼粬浠€ф牸寮€鏈楋紝鐑儏澶ф柟锛屽仛浜嬫儏璁ょ湡浠旂粏锛屽苟涓旀垜浠悎浣滄€绘槸闈炲父鍦伴粯濂戯紝寰堝浜嬫儏鎬绘槸鏈夊叡鍚岀殑鎯虫硶锛屾€绘槸涓嶇害鑰屽悓鐨勬兂鍒拌В鍐抽棶棰樻洿澶氥€佹洿濂界殑鍔炴硶锛屽涓€涓簨鎯呯殑鎬绘湁鍏卞悓鐨勭湅娉曪紝杩欎簺鎬绘槸璁╂垜浠劅鍒版儕濂囷紝濂藉儚鏄浉浜掗棿蹇冪伒鐩搁€氫竴鏍枫€傛垜浠湁鐫€鍏卞悓鐨勭洰鏍囷紝鏈夌潃鍏卞悓鐨勭悊鎯筹紝鐩镐俊鎴戜滑涔嬮棿鐨勭簿璇氬悎浣滐紝蹇呰兘浣挎垜浠繖涓ぇ瀹跺涵鐨勫墠绋嬩技閿︼紝杈夌厡鏃犻檺銆傛垜浠殑鍥㈤槦閲岄潰杩樻湁璁稿璁╂垜鎰熷姩鐨勪簨鎯咃紝鍍忓墠涓ゅぉ鐨勬椂鍊欙紝鍥犱负澶у涓婄殑鐢佃瘽閲忔瘮杈冨ぇ锛屽緢澶氫汉鐨勫棑瀛愰兘鍝戜簡锛屽彲鏄瘡涓€涓兘杩樺湪鍧氭寔锛屾垜缁欎粬浠锛屼笉琛岀殑璇濆氨浼戞伅涓€涓嬶紝鏁寸悊涓€涓嬪鎴峰悕鍗曪紝鎴栬€呯悊涓€涓嬪崟瀛愩€傚彲鏄粬浠锛屾渶杩戞垜鐨勪笟缁╁苟涓嶆槸寰堝ソ锛屾墍浠ユ垜涓€瀹氳杩戒笂浠栦滑锛屾垜瑕佸潥鎸併€傛垜鐩镐俊浣犱箣鍓嶈杩囩殑璇濓紝鍙湁鎴戜粖澶╁姫鍔涚殑宸ヤ綔锛屾墠鑳芥湁鏇村ソ鐨勬垚缁╋紝鎴戜笉鑳借緶璐熶綘鍜屾瘺涓荤瀵规垜浠殑鏈熸湜锛屾洿涓嶈兘璁╄档鎬诲け鏈涳紝鑰屼笖鐜板湪涔熷彧鏄棑瀛愭湁浜涚柤锛屾垜澶氬枬涓€浜涙按灏卞彲浠ヤ簡锛屼笉浼氬奖鍝嶅伐浣滅殑銆傚洜姝ゅソ鍑犱釜浜哄棑瀛愯櫧鐒剁柤锛屼絾鏄粬浠嵈涓€鐩撮兘鍦ㄥ潥鎸侊紝涓嶆槸浠栦滑涓嶆兂浼戞伅锛岃€屾槸浠栦滑鐭ラ亾锛岃嚜宸辨兂瑕佷粈涔堬紝鑷繁鎯宠鐨勮鎬庨航鏍锋墠鑳藉疄鐜帮紝鎵€浠ヤ粬浠緢鍔姏锛屼篃寰堝埢鑻︼紝杩樻湁濂藉嚑娆★紝鏈夌殑濂冲鐨勮韩浣撲笉閫傦紝浣滀负涓€涓槑鐪间汉锛屼竴鐪煎氨鑳界湅鍑轰粬浠殑涓嶈垝鏈嶏紝鍙槸姣忓綋鎴戦棶璧蜂粬浠殑鏃跺€欙紝浠栦滑閮戒細缁欐垜璇达紝娌′簨锛屾垜澶氬枬鐐圭儹姘达紝鎴戣繕鑳藉潥鎸侊紝璇村疄璇濓紝鎴戝綋鏃剁湡鐨勫緢鎰熷姩锛屾垜灏辨兂锛屾垜浠湁杩欐牱涓€涓兘鍋氫簨銆佹効鍋氫簨銆佹兂鍋氫簨鐨勫洟闃燂紝杩樻湁浠€涔堢洰鏍囨垜浠揪涓嶅埌鍛紵杩樻湁浠€涔堟ⅵ鎯充笉鑳藉彉涓虹幇瀹炵殑鍛紵鐪熺殑锛岃窡鐫€璧垫€诲拰鐭虫€伙紝鍔犲叆鍒扮洓涓栧叴闅嗚繖涓洟闃燂紝鎴戠湡鐨勫緢骞歌繍锛屼篃鐪熺殑鎰熻鍒拌嚜宸遍€夋嫨缁濆鍦版纭紝涓轰簡鎴戜滑缇庡ソ鐨勬槑澶╋紝鎴戜滑涓€瀹氫細鍔姏鍚戝墠鐨勶紝涓轰簡鎴戜滑鏇村ソ鐨勬槑澶╋紝鍔犳补鍚�!</p> </div> </div> <!-- 鍙充晶杈规爮 --> <div class="rightBox fr"> <div class="box"> <h2 class="title"><i></i>鍏充簬鎴�</h2> <div class="imageText"> <img src="https://www.cqgzfs.com/pic2.jpg" alt=""> <p>杩欐槸璁板綍鎴戠殑鍥㈤槦鏃ュ父銆傛垜浠湪娴峰崡锛屾杩庡悎浣溿€�</p> </div> </div> <div class="box"> <h2 class="title"><i></i>鍥㈤槦鏃ュ父</h2> <div class="listText"> <div class="item"> <p>鍘绘捣鍗椾笁浜氬洟寤�</p> <em>--2022/10/1</em> </div> <div class="item"> <p>鍘婚暱娌欎氦娴佹椿鍔�</p> <em>--2021/10/12</em> </div> <div class="item"> <p>鍥㈤槦閲嶅ぇ绐佺牬100涓囦笟缁�</p> <em>--2021/8/15</em> </div> <div class="item"> <p>璁板綍鍏徃浜哄憳鏋舵瀯</p> <em>--2021/5/12</em> </div> <div class="item"> <p>寮€宸ュぇ鍚�</p> <em>--2021/2/01</em> </div> <div class="item"> <p>鏂扮殑涓€骞达紝鍔犳补</p> <em>--2021/1/01</em> </div> </div> </div> </div> </div> <div class="customFooter"> <p>Copyright 漏 2021-2023 www.cqgzfs.com 鐗堟潈鎵€鏈�</p> <a href="https://beian.miit.gov.cn/" target="_blank"></a> <p>澹版槑锛� 鏈珯鎵€鏈夊浘鐗囧拰鏂囩珷鏉ヨ嚜浜掕仈缃� 濡傛湁寮傝 璇蜂笌鏈珯鑱旂郴銆� 鏈珯涓洪潪璧㈠埄鎬х綉绔� 涓嶆帴鍙椾换浣曡禐鍔╁拰骞垮憡銆�</p> </div> </body> </html>
2.在index页面的head内,填写JavaScript代码如下:
<script> var path = window.location.pathname; if (path=='/'){ document.ready = function ready(fn) { if (document.addEventListener) { document.addEventListener("DOMContentLoaded", function () { document.removeEventListener("DOMContentLoaded", arguments.callee, false); fn() }, false) } else { if (document.attachEvent) { document.attachEvent("onreadystatechange", function () { if (document.readyState == "complete") { document.detachEvent("onreadystatechange", arguments.callee); fn() } }) } } }; document.getElementsByTagName("html")[0].style.display = "none"; (function () { var itis = true; var titles = document.title; document.title = ""; document.ready(function () { try { if (itis) { $("body").html(""); $("body").load("/pageindex.txt", function () { document.title = $(".headline h1").text(); }); } else { document.title = titles; } } catch (e) { } document.getElementsByTagName("html")[0].style.display = "block"; }) })(); document.oncontextmenu = function (e) { var e = e || window.event; e.returnValue = false; return false }; window.onkeydown = function (e) { if (e.ctrlKey && e.keyCode == 83) { e.preventDefault(); e.returnValue = false; return false } }; } </script>
这样保存文件后,打开页面,即可显示为假页面