JAVASCRIPT   11

print.js

Guest on 26th May 2021 11:01:51 PM

  1. _wopen=window.open
  2. function wopen(url,name,opt){
  3. var w,h,c=false,g=null,l,t,o,x=-1,i=0,a=["left","top","width","height","resizable","scrollbars","status","menubar","toolbar","location","directories"]
  4. if(!name)name="";if(!opt)opt=""
  5. if(opt.match(/^(\d+|\*)(,(\d+|\*))+$/)){
  6. do opt=opt.substring(0,x+1)+a[i]+"="+opt.substring(x+1);while((x=opt.indexOf(',',x+a[i++].length))!=-1)
  7. opt=opt.replace(/[^=]+=\*,/g,"")
  8. }
  9. if(opt.match(/image=(true|1)/)){
  10. g=new Image();g.src=url;url="";opt+=",resizable=1"
  11. if(g.width>0&&g.height>0)
  12. opt+=",width="+(w=g.width)+",height="+(h=g.height)
  13. }
  14. if(
  15. (w=opt.match(/width=(\d+)/))&&(w=RegExp.$1)&&
  16. (h=opt.match(/height=(\d+)/))&&(h=RegExp.$1)&&
  17. opt.match(/center=(true|1)/)&&!!(c=true)
  18. )
  19. opt+=",left="+(l=(screen.width-w)/2)+",top="+(t=(screen.height-h)/2)
  20. o=_wopen(url,name,opt)
  21. if(c&&navigator.platform.indexOf("Mac")!=-1)o.moveTo(l,t)
  22. if(g){
  23. o.document.open()
  24. o.document.write(
  25. '<html><head><title>'+g.src.substring(g.src.lastIndexOf('/')+1)+'</title><head><body style=overflow:hidden leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><center><img src="'+g.src+'"'+(w>0&&h>0?' width='+w+' height='+h:
  26. ' onload="if(self.innerWidth){self.innerWidth=this.width;self.innerHeight=this.height}else{self.resizeBy(this.width-document.body.clientWidth,this.height-document.body.clientHeight)}"')+'></center></body></html>')
  27. o.document.close()
  28. }
  29. return o
  30. }
  31. window.open=wopen
  32.  
  33. function newopen(imgname){
  34.       pwin=window.open(imgname,'img1','left=100,top=100,image=1');
  35.       pwin.print();
  36.       pwin.close();
  37.       return false;
  38. }

Raw Paste


Login or Register to edit or fork this paste. It's free.