从一个.js文件引用到另一个 [英] Reference from one .js file to another

查看:124
本文介绍了从一个.js文件引用到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用javascript书签引用外部路径

I use javascript bookmarklet with reference to extern path

javascript:(function(){var s = document.createElement('script');s.src = 'http://192.168.0.100/my.js';document.body.appendChild(s);})();

如何创建对my.js文件所在目录中的jQuery.js文件的引用?

How I can create reference to jQuery.js file that is located in the same directory that my.js file?

我可以将CSS文件附加到此文件吗?

Can I attah css file to this files?

推荐答案

javascript:(function(){
    var s = document.createElement('script');
    s.src = 'http://192.168.0.100/my.js';
    document.body.appendChild(s);
    // Additional js file
    s = document.createElement('script');
    s.src = '<jQuery location goes here>';
    document.body.appendChild(s);
    // CSS file
    s = document.createElement('link');
    s.rel = "stylesheet";
    s.href = "<location goes here>";
    s.type = "text/css";
    document.body.appendChild(s);
})();

这篇关于从一个.js文件引用到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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