Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

javascript: open 2 windows and slide them over the screen to a meeting point

Hi, got a JS-problem:

I want open 2 small windows on different positions of the screen. Then they should move/slide over the screen to meet each other in a point.
This script should also work with different  screen resolutions. I need it urgent.

Thanx in advance
Raduis
0
raduis
Asked:
raduis
  • 3
1 Solution
 
superslamwichCommented:
try this script:

<script language='javascript'>
<!--
  //Set location of two windows
  win1loc = 'page1.html'
  win2loc = 'page2.html'

  //Set x and y coordinates of first window
  Xwin1 = 100
  Ywin1 = 100

  //Set x and y coordinates of second window
  Xwin2 = 800
  Ywin2 = 100

  //Set height and width of first window
  widthwin1 = 300
  heightwin1 = 300

  //Set height and width of second window
  widthwin2 = 300
  widthwin2 = 300

  //Set speed for the two to move together(milliseconds) and pixels moved per amount of time
  speed = 20
  pixelsper = 1
 
  function openwins()  {
    win1 = window.open(win1loc,'win1','height = ' + heightwin1 + ',width = ' + widthwin1 + 'left = ' + Xwin1 + ', top = ' + Ywin1)
    win2 = window.open(win2loc,'win2','height = ' + heightwin2 + ',width = ' + widthwin2 + 'left = ' + Xwin2 + ', top = ' + Ywin2)
    movewins()  {
  }
  spacebetween = (Xwin1 + heightwin1) - Xwin2
  function movewins()  {
    if(spacebetween > 0)  {
      win1.moveBy(pixelsper,0)
      win2.moveBy(-pixelsper,0)
      spacebetween -= pixelsper
      setTimeout('movewins()',speed)
    }
  }
0
 
superslamwichCommented:
ok,  a few corrections to make.  Here's what the code needs to be:

<script language='javascript'>
<!--
  //Set location of two windows
  win1loc = 'test.html'
  win2loc = 'testit2.html'

  //Set x and y coordinates of first window
  Xwin1 = 100
  Ywin1 = 100

  //Set x and y coordinates of second window
  Xwin2 = 800
  Ywin2 = 100

  //Set height and width of first window
  widthwin1 = 300
  heightwin1 = 300

  //Set height and width of second window
  widthwin2 = 300
  heightwin2 = 300

  //Set speed for the two to move together(milliseconds) and pixels moved per amount of time
  speed = 20
  pixelsper = 1
 
  spacebetween = (Xwin2 - Xwin1 - widthwin1)/2
  function openwins()  {
    win1 = window.open(win1loc,'win1','height = ' + heightwin1 + ',width = ' + widthwin1 + ',left = ' + Xwin1 + ', top = ' + Ywin1)
    win2 = window.open(win2loc,'win2','height = ' + heightwin2 + ',width = ' + widthwin2 + ',left = ' + Xwin2 + ', top = ' + Ywin2)
    movewins()
  }
  function movewins()  {
    if(spacebetween > 0)  {
      win1.moveBy(pixelsper,0)
      win2.moveBy(-pixelsper,0)
      spacebetween -= pixelsper
      setTimeout('movewins()',speed)
    }
  }
//-->
</script>
<body onLoad='javascript:openwins()'>

This works fine on my computer(I have IE6), hope it works for you.

{Slam}
0
 
superslamwichCommented:
Oh, just a note. The only way this will work is if the two windows you are opening are windows on your site.  I tried using it with opening google and yahoo, and it gave me an error message

{Slam}
0
 
jaysolomonCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: superslamwich {http:#8242000}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now