jQuery Bookmarklet

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery Bookmarklet相关的知识,希望对你有一定的参考价值。

Enable jQuery on any website, just clicking on a bookmarklet with this code. Or drag & drop this on your bookmark bar: <a href="javascript:(function(){var%20s=document.createElement('script');s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js');if(typeof%20jQuery!='undefined'){var%20msg='This%20page%20already%20using%20jQuery%20v'+jQuery.fn.jquery;}else{document.getElementsByTagName('head')[0].appendChild(s);var%20msg='This%20page%20is%20now%20jQuerified';}var%20el=document.createElement('div');el.style.position='fixed';el.style.height='30';el.style.width='200';el.style.margin='0%20auto%200%20auto';el.id='jq-kswedberg';el.style.top='0';el.style.left='40%';el.style.padding='5px%2010px%205px%2010px';el.style.backgroundColor='#f99';el.innerhtml=msg;var%20b=document.getElementsByTagName('body')[0];b.appendChild(el);window.setTimeout(function()%20{jQuery('#jq-kswedberg').fadeOut('slow',function(){jQuery(this).remove()});},2500);})();">$jQ</a>
  1. (function() {
  2. var s=document.createElement('script');
  3. s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js');
  4. if(typeof jQuery!='undefined') {
  5. var msg='This page already using jQuery v' + jQuery.fn.jquery;
  6. } else {
  7. document.getElementsByTagName('head')[0].appendChild(s);
  8. var msg='This page is now jQuerified'
  9. }
  10. var el=document.createElement('div');
  11. el.style.position='fixed';
  12. el.style.height='30';
  13. el.style.width='200';
  14. el.style.margin='0 auto 0 auto';
  15. el.id='jq-kswedberg';
  16. el.style.top='0';
  17. el.style.left='40%';
  18. el.style.padding='5px 10px 5px 10px';
  19. el.style.backgroundColor='#f99';
  20. el.innerHTML=msg;
  21. var b=document.getElementsByTagName('body')[0];
  22. b.appendChild(el);
  23. window.setTimeout(function() {
  24. jQuery('#jq-kswedberg').fadeOut('slow',function() {
  25. jQuery(this).remove()
  26. });
  27. }, 2500);
  28. })();

以上是关于jQuery Bookmarklet的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript 带有jquery的bookmarklet

JavaScript jQuery Bookmarklet

JavaScript jQuery bookmarklet:在页面上找到重复的ID

jQuery应用 代码片段

Visual Studio 2012-2019的130多个jQuery代码片段。

markdown 在WordPress中使用jQuery代码片段