且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在目标页面***问jQuery的现有副本

更新时间:2023-12-03 08:09:46

使用 现有 的jQuery副本,代码如下:

Use an existing copy of jQuery with code like this:

function main () {
    /*--- Put all of your code here.
        Use jquery with $ or however the target page uses it.
    */
}

function addJS_Node (text, s_URL, funcToRun) {
    var D                                   = document;
    var scriptNode                          = D.createElement ('script');
    scriptNode.type                         = "text/javascript";
    if (text)       scriptNode.textContent  = text;
    if (s_URL)      scriptNode.src          = s_URL;
    if (funcToRun)  scriptNode.textContent  = '(' + funcToRun.toString() + ')()';

    var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
    targ.appendChild (scriptNode);
}

addJS_Node (null, null, main);