Loading...

Category: JavaScript

  • The SourceBench 2:47 pm on December 21, 2009 Permalink | Reply
    Tags: context menu, disable, , right click   Posted in JavaScript

    Disable right click context menus with jQuery 

    $(document).ready(function(){
      $(document).bind("contextmenu",function(e){
        return false;
      });
    });

     
  • The SourceBench 11:32 pm on November 27, 2009 Permalink | Reply
    Tags: external links, images, ,   Posted in JavaScript

    Add an image to all external links (identified by the class extlinks) 

    $(document).ready(function() {
      $('#extlinks a').filter(function() {
     return this.hostname && this.hostname !== location.hostname;
      }).after(' <img src="/images/external.png" alt="external link"/>');
    });

     
  • The SourceBench 12:32 pm on November 27, 2009 Permalink | Reply
    Tags: browser, explorer, , , internetexplorer, png, pngfix, quirk   Posted in JavaScript

    Fixes the png 24 bit transparency with Internet Explorer 

    //<!--[if lt IE 7]>
    //<script type="text/javascript" src="unitpngfix.js"></script>
    //<![endif]-->
    var clear="images/clear.gif"; //path to clear.gif
    
    document.write('<script type="text/javascript" id="ct" defer="defer" src="javascript:void(0)"><\/script>');var ct=document.getElementById("ct");ct.onreadystatechange=function(){pngfix()};pngfix=function(){var els=document.getElementsByTagName('*'),ip=/\.png/i,al="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='",i=els.length,uels=new Array(),c=0;while(i-->0){if(els[i].className.match(/unitPng/)){uels[c]=els[i];c++;}}if(uels.length==0)pfx(els);else pfx(uels);function pfx(els){i=els.length;while(i-->0){var el=els[i],es=el.style,elc=el.currentStyle,elb=elc.backgroundImage;if(el.src&&el.src.match(ip)&&!es.filter){es.height=el.height;es.width=el.width;es.filter=al+el.src+"',sizingMethod='crop')";el.src=clear;}else{if(elb.match(ip)){var path=elb.split('"'),rep=(elc.backgroundRepeat=='no-repeat')?'crop':'scale',elkids=el.getElementsByTagName('*'),j=elkids.length;es.filter=al+path[1]+"',sizingMethod='"+rep+"')";es.height=el.clientHeight+'px';es.backgroundImage='none';if(j!=0){if(elc.position!="absolute")es.position='static';while(j-->0)if(!elkids[j].style.position)elkids[j].style.position="relative";}}}}}}
    

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
esc
cancel