home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 May / comcd0502.iso / homepage / special / javascript / 10_01 / jscript / popupfly / utilpopupfly2.js < prev    next >
Encoding:
JavaScript  |  2001-07-30  |  3.4 KB  |  135 lines

  1. // CREDITS:
  2. // Flying Popup Generator
  3. // by Urs Dudli and Peter Gehrig 
  4. // Copyright (c) 2001 Peter Gehrig and Urs Dudli. All rights reserved.
  5. // Permission given to use the script provided that this notice remains as is.
  6. // Additional scripts can be found at http://www.24fun.com
  7. // info@24fun.com
  8. // 4/6/2001
  9.  
  10. // IMPORTANT: 
  11. // If you add this script to a script-library or script-archive 
  12. // you have to add a link to http://www.24fun.com on the webpage 
  13. // where this script Script will be running.
  14.  
  15. // INSTRUCTIONS: 
  16. // Got to http://www.24fun.com, open category 'utility' and
  17. // generate your own Flying Popup with the new Flying Popup Generator
  18.  
  19. var popwindow
  20. var thistoolbar
  21. var thislocation
  22. var thisdirectories
  23. var thisstatus
  24. var thismenubar
  25. var thisscrollbars
  26. var thisresizable
  27. var thisurl
  28. var thiswidth
  29. var thisheight
  30. var thisdirection
  31. var thistopposition
  32. var thisleftposition
  33. var pause=20
  34. var stepfactor=20
  35. var stepx
  36. var stepy
  37.  
  38. var marginpadding=23
  39.  
  40. var startleft=0
  41. var endleft=0
  42. var starttop=0
  43. var endtop=0
  44.  
  45. var marginleft=0
  46. var margintop=0
  47. var marginright
  48. var marginbottom
  49. var timer
  50.  
  51. function openpopup() {
  52.  
  53.     thistoolbar=tistoolbar
  54.     thislocation=tislocation
  55.     thisdirectories=tisdirectories
  56.     thisstatus=tisstatus
  57.     thismenubar=tismenubar
  58.     thisscrollbars=tisscrollbars
  59.     thisresizable=tisresizable
  60.     thisurl=tisurl
  61.     thiswidth=tiswidth
  62.     thisheight=tisheight
  63.     thisdirection=tisdirection
  64.     
  65.     marginright=screen.width
  66.     marginbottom=screen.height
  67.  
  68.     if (thisdirection=="horitop") {
  69.         startleft=marginleft
  70.         endleft=marginright-thiswidth-marginpadding
  71.         starttop=marginpadding
  72.         endtop=starttop
  73.         stepx=stepfactor
  74.         stepy=0    
  75.     }
  76.     if (thisdirection=="horimiddle") {
  77.         startleft=marginleft
  78.         endleft=marginright-thiswidth-marginpadding
  79.         starttop=Math.round((marginbottom-thisheight)/2)
  80.         endtop=starttop
  81.         stepx=stepfactor
  82.         stepy=0    
  83.     }
  84.     if (thisdirection=="horibottom") {
  85.         startleft=marginleft
  86.         endleft=marginright-thiswidth-marginpadding
  87.         starttop=marginbottom-thisheight-2*marginpadding
  88.         endtop=starttop
  89.         stepx=stepfactor
  90.         stepy=0    
  91.     
  92.     }
  93.     if (thisdirection=="vertileft") {
  94.         startleft=marginleft
  95.         endleft=startleft
  96.         starttop=marginpadding
  97.         endtop=marginbottom-thisheight-2*marginpadding
  98.         stepx=0
  99.         stepy=stepfactor    
  100.     }
  101.     if (thisdirection=="vertimiddle") {
  102.         startleft=Math.round((marginright-thiswidth)/2)
  103.         endleft=startleft
  104.         starttop=marginpadding
  105.         endtop=marginbottom-thisheight-2*marginpadding
  106.         stepx=0
  107.         stepy=stepfactor    
  108.     }
  109.     if (thisdirection=="vertiright") {
  110.         startleft=marginright-thiswidth-marginpadding
  111.         endleft=marginright-thiswidth-marginpadding
  112.         starttop=marginpadding
  113.         endtop=marginbottom-thisheight-2*marginpadding
  114.         stepx=0
  115.         stepy=stepfactor    
  116.     }
  117.     popwindow=window.open(thisurl, "newwindow", "toolbar="+thistoolbar+",location="+thislocation+",directories="+thisdirectories+",status="+thisstatus+",menubar="+thismenubar+",scrollbars="+thisscrollbars+",resizable="+thisresizable+",width="+thiswidth+",height="+thisheight+",top="+starttop+",left="+startleft+"")
  118.     movewindow()
  119.     popwindow.focus()
  120. }
  121.  
  122. function movewindow() {
  123.     if ((starttop<=endtop) && (startleft<=endleft)){
  124.         popwindow.moveTo(startleft,starttop)
  125.         startleft+=stepx
  126.         starttop+=stepy
  127.         timer=setTimeout("movewindow()",pause)
  128.     }
  129.     else {
  130.         clearTimeout(timer)
  131.         popwindow.moveTo(endleft,endtop)
  132.     }
  133. }
  134.  
  135. window.onload=openpopup