?
Solved

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

Posted on 2003-03-31
5
Medium Priority
?
220 Views
Last Modified: 2012-05-04
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
Comment
Question by:raduis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 3

Expert Comment

by:superslamwich
ID: 8241913
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
 
LVL 3

Accepted Solution

by:
superslamwich earned 500 total points
ID: 8242000
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
 
LVL 3

Expert Comment

by:superslamwich
ID: 8242020
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10150359
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question