Solved

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

Posted on 2003-03-31
Medium Priority
220 Views
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.

0
[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
• 3

LVL 3

Expert Comment

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

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>

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

{Slam}
0

LVL 3

Expert Comment

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

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}

jAy
EE Cleanup Volunteer
0

Featured Post

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
Course of the Month12 days, 5 hours left to enroll