六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 124|回复: 0

简单的动态加载 js 和 css

[复制链接]

升级  9.33%

16

主题

16

主题

16

主题

秀才

Rank: 2

积分
64
 楼主| 发表于 2013-2-8 00:21:44 | 显示全部楼层 |阅读模式
function importJs(filename)
{
    var ref = document.createElement("script");
    ref.setAttribute("type", "text/javascript");
    ref.setAttribute("src", filename);

    if (typeof ref != undefined)
         document.getElementsByTagName("head")[0].appendChild(ref);
}
function importCss(filename)
{
    var ref=document.createElement("link");
    ref.setAttribute("rel", "stylesheet");
    ref.setAttribute("type", "text/css");
    ref.setAttribute("href", filename);

    if (typeof ref != undefined)
         document.getElementsByTagName("head")[0].appendChild(ref);
}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表