当页脚链接发生更改时替换正文内容

replace body content when footer links have changed

本文关键字:替换 正文 链接 接发      更新时间:2023-09-26

我需要用JavaScript或jquery保护我的主题上的版权链接。

<div id="footer"><a href="http://example.com" id="example">copyright</a></div>

如果页脚链接或文本已更改,请将正文内容替换为我的消息:"请不要删除我的链接"。

这是可以/可以工作的东西。

请记住,在

页脚链接出现在页面上后,需要调用 javscript。

.HTML:

<body>
  <div class="body-content" id="bodyContentId">
    Here is the body content.
  </div>
  <div class="footer">
    <a href='www.google.com' id="someLink">
      Some Link
    </a>
  </div>
  <script type="text/javascript">
    if( document.getElementById('someLink') == null || document.getElementById('someLink').getAttribute('href') != "www.google.com"){
      document.getElementById("bodyContentId").innerHTML = "Don't remove my links";
    }
  </script>
</body>
然后

,您可以修改javascript以反映您的特定链接,然后使用Dean Edwards的Packer http://dean.edwards.name/packer/之类的工具对其进行打包/混淆

这会像这样显示您的代码(基于上面的示例 JS):

Javascript:

eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'''w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('''b'+e(c)+'''b','g'),k[c]);return p}('8(1.0(''2'')==4||1.0(''2'').5(''6'')!="7.3.9"){1.0("a").b="c''d e f g"}',17,17,'getElementById|document|someLink|google|null|getAttribute|href|www|if|com|bodyContentId|innerHTML|Don|t|remove|my|links'.split('|'),0,{}))

如本小提琴 http://jsfiddle.net/jH5z4/所示,通过更改/删除链接或更改地址 href,它将修改正文内容。