【问题标题】:Dynamically modify head tag from web page in a从网页中动态修改head标签
【发布时间】:2014-09-13 22:23:33
【问题描述】:

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

改变 %3C%2FHEAD%3E 到 %3Clink+rel%3D%27shortcut+icon%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>

【问题讨论】:

    标签: javascript jquery dhtml


    【解决方案1】:

    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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-07
      • 2014-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      相关资源
      最近更新 更多