当页脚链接发生更改时替换正文内容
replace body content when footer links have changed
我需要用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,它将修改正文内容。
相关文章:
- 无法从 jQuery RSS Feed 中的 localStorage 动态替换类
- 我如何找到一个句子中的所有空格并替换忽略它们
- 如何用更合适的内容替换document.write
- 是否有任何方法可以使用jQuery替换在数组中定义值的文本
- 在DOM中查找一个模式并替换它's的内容使用jquery
- 用空格替换下划线PHP
- str.split(someString).join(someOtherString)是否等效于替换
- 使用javascript的图像替换循环
- window.location替换并传递URL历史记录条目中的变量
- javascript问题正文样式
- 替换标记中的属性
- 指令的模板必须只有一个根元素:With restrict E&替换true
- AngularJs对ng消息的自定义替换
- 当页脚链接发生更改时替换正文内容
- 正文HTML中的文本没有被正确替换
- 如何将html正文部分的
字符替换为
- 如何将正文中的数字替换为波斯数字
- 使用JS替换Gmail邮件正文中的文本
- 替换文档正文中的所有单词不起作用
- 替换正文中的单词