如何在书签中嵌套 jquery 和 jquery-ui 的 cdn 加载?

发布于 2024-10-10 10:55:47 字数 1154 浏览 1 评论 0 原文

我在书签中找到了链接和加载 jquery 的示例,但找不到同时加载 jquery 和 jquery-ui 的情况。

这是我正在研究的要点: 链接文本 更新以下要点现在可以使用。

<a href='javascript:(function(e,a,g,h,f,z,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js";c.onload=c.onreadystatechange=function(){z=a.createElement("script");z.type="text/javascript";z.src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js";z.onload=z.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}}})(window,document,"1.4.4",function($,L){/*ENTER JQUERY-UI CODE HERE*/});'>CC</a>

I found examples of linking and loading jquery in bookmarklets but couldn't find a case where both jquery and jquery-ui were both loaded.

Here's the gist I'm working on:
link text
update the following gist is functional now.

<a href='javascript:(function(e,a,g,h,f,z,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js";c.onload=c.onreadystatechange=function(){z=a.createElement("script");z.type="text/javascript";z.src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js";z.onload=z.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}}})(window,document,"1.4.4",function($,L){/*ENTER JQUERY-UI CODE HERE*/});'>CC</a>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眸中客 2024-10-17 10:55:47

我得到了以下小书签,可以使用:

    javascript:
(function(){
  var s1=window.document.createElement('script');
  s1.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js');
  window.document.body.appendChild(s1);
  var s2=window.document.createElement('script');
  s2.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js');
  window.document.body.appendChild(s2);
  s1.onload=s1.onreadystatechange=function(){
    if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){
      s2.onload=s2.onreadystatechange=function(){
        if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){
          $('div').draggable();
          $('div').resizable();
          $('div').css({'border-style':'dashed','border-width':'3px','border-color':'black','background':'#00ccFF'});
        }
      }
      ;
    }
  }
  ;
}
)();

这是同一个小书签,压缩后的空白已被清除并可供使用:

javascript:(function(){var s1=window.document.createElement('script');s1.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js');window.document.body.appendChild(s1);var s2=window.document.createElement('script');s2.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js');window.document.body.appendChild(s2);s1.onload=s1.onreadystatechange=function(){if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){s2.onload=s2.onreadystatechange=function(){if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){$('div').draggable();$('div').resizable();$('div').css({'border-style':'dashed','border-width':'3px','border-color':'black','background':'#00ccFF'});}};}};})();

参考资料:

I got the following bookmarklet to work:

    javascript:
(function(){
  var s1=window.document.createElement('script');
  s1.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js');
  window.document.body.appendChild(s1);
  var s2=window.document.createElement('script');
  s2.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js');
  window.document.body.appendChild(s2);
  s1.onload=s1.onreadystatechange=function(){
    if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){
      s2.onload=s2.onreadystatechange=function(){
        if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){
          $('div').draggable();
          $('div').resizable();
          $('div').css({'border-style':'dashed','border-width':'3px','border-color':'black','background':'#00ccFF'});
        }
      }
      ;
    }
  }
  ;
}
)();

Here's the same bookmarklet compressed with white spaces purged and ready for use:

javascript:(function(){var s1=window.document.createElement('script');s1.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js');window.document.body.appendChild(s1);var s2=window.document.createElement('script');s2.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js');window.document.body.appendChild(s2);s1.onload=s1.onreadystatechange=function(){if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){s2.onload=s2.onreadystatechange=function(){if(!this.readyState||this.readyState=='loaded'||this.readyState=='complete'){$('div').draggable();$('div').resizable();$('div').css({'border-style':'dashed','border-width':'3px','border-color':'black','background':'#00ccFF'});}};}};})();

References:

  • I found the following site very helpful for improving the readability and writing bookmarklets: subsimple.com
  • Also for testing jsfiddle.net proved very helpful while on the go
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文