动态修改网页中的头标记

时间:2014-07-22 21:56:10

标签: javascript jquery dhtml

我有一个域名注册商,在进行域名转发时,它会将您的网站包装在框架集中 所以我想要做的就是在标签下方添加一行来定义FAVICON.ICO 喜欢这个

变化 %3C%2FHEAD%3E     至 %3Clink +相对%3D%27shortcut +图标%27 + HREF%3D%27%2FPictureLibrary%2Ffavicon.ico%27 +%2F%3E %3C%2FHEAD%3E

我怎么能用jquery或动态javascript / html做到这一点?

<html>
  <head>
    <title>smdug.tk</title>
    <meta name="description" content="smdug.tk">
    <meta name="keywords" content="bodyareaframe,accessible,content">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <frameset rows="*">
    <frame frameborder=0 src="http://portal.merrittnet.org/smdug" name="dot_tk_frame_content" scrolling="auto" noresize>
  </frameset>
</html>

1 个答案:

答案 0 :(得分:0)

javaScript代码:

<script>
        icon_link = document.createElement('link'); //create an <link> tag
 // add attributes to the <link> tag 
        icon_link.rel = 'shortcut icon';                    
        icon_link.href = 'PictureLibrary-favicon.ico';  
        icon_link.type = 'image/x-icon';
// attach created <link> tag along with it's attributes to DOM 
        document.getElementsByTagName('head')[0].appendChild(icon_link);
</script>