使用Javascript从页面中删除或隐藏javascript [英] Removing or hiding javascript from a page using Javascript

查看:95
本文介绍了使用Javascript从页面中删除或隐藏javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站www.misaqyrn.somee.com上,您会看到以下代码:

On my site hosted at www.misaqyrn.somee.com you see this code:

<!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->
<center><a href="http://somee.com">Web hosting by Somee.com</a></center>
</textarea></xml></script></noframes></noscript></object></style></title></applet>
<script language="JavaScript" src="http://ads.mgmt.somee.com/serveimages/ad2/WholeInsert4.js">    </script>
<!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->





i希望通过java脚本或jquery删除或隐藏此代码。 www.somee.com是免费托管,这是此代码已添加到我的网站末尾的原因



i want delete or hiding this code by java script or jquery. www.somee.com is free hosting which is the reason this code has been added to the end of my site

推荐答案

在javascript中你可以做到。



In javascript you can do it.

var body = document.getElementsByTagName("body")[0];
var scriptElements = document.getElementByTagName("script");
for(var count = 0; count < scriptElements.length; count++) {
    if(scriptElements[count].src == 'The script path') { // Here the source is >> ads.mgmt.somee.com/serveimages/ad2/WholeInsert4.js
        body.removeChildNode(scriptElements[count]);
        break;
    }
}


我想要视频的完整详情


Sol:请看我的下面的示例替换了锚元素之间的文本,它对我有用:



Sol: Please see my below sample to replace the text between the anchor element, and it worked for me:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->
       <center><a href="http://somee.com">Web hosting by Somee.com</a></center>
       <!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->
    </div>
        <script lang="javascript">
            document.body.innerHTML = document.body.innerHTML.replace('Web hosting by Somee.com', '')
        </script>
    </form>
</body>
</html>







建议:我的建议是你带这样的消息没有显示或离开的付费托管消息原样(根据他的条款和条件)。




suggestion: My suggestion is either you take a paid hosting where this kind of a message is not display or leave the message as it is (as per his terms and conditions).


这篇关于使用Javascript从页面中删除或隐藏javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆