Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:10:36+00:00 2026-06-03T05:10:36+00:00

I am new to JavaScript and just started learning window methods. I wanted to

  • 0

I am new to JavaScript and just started learning window methods.
I wanted to write this method to get a new window to move from the left end to the right end of the screen. However, the code doesn’t work.

Could someone please tell me where I’ve gone wrong.

    <!doctype html>
<html>
<title>Avoid Window</title>
<head>
<script type="text/javascript">
    var MovingWindow;   

    function CreateWindow()
    {
        MovingWindow = window.open('','MovingWindow','width=100,height=100,menubar=0,toolbar=0,location=0,resizeable=0,status=0');
        window.MovingWindow.moveTo(0,0);
        while( window.MovingWindow.screenX < window.screen.width - window.MovingWindow.width)
        {

            window.MovingWindow.moveBy(1,0);
        }

    }
</script>
</head>
<body>
<h1>Avoid Window</h1>
<p> Click on the button below to create a window which moves from one end of the screen to the other end of the screen</p>
<input type="Button" onClick="CreateWindow();" value="Create Window"/>
<input type="Button" onClick="MoveWindow();" value="Move Window"/>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:10:37+00:00Added an answer on June 3, 2026 at 5:10 am

    You can’t do animations in a loop. As long as the function is running, the user interface is not updated. Your function will change the coordinates of the window, and when the function ends the window will be redrawn at the final position.

    Use the window.setInterval method to start an interval where you can move the window:

    var timer = window.setInterval(function(){
      if (window.MovingWindow.screenX < window.screen.width - window.MovingWindow.width) {
        window.MovingWindow.moveBy(1,0);
      } else {
        window.clearInterval(timer);
      }
    }, 100);
    

    However, as Daniel A. pointed out, some browsers doesn’t allow client script to move windows. If it doesn’t work in your browser, you can change the settings just to test that the setInterval approach works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning Jquery and am new to writing javascript (I am
I just started learning javascript for 2 weeks so I'm pretty new to it.
I just started using JSON and found this example from http://imdbapi.com/ : <script type=text/javascript>
im new at javascript and i can get this slider to work but not
I've just started using the console in Chrome Developer Tools (pretty new to Javascript
We have just started our new assignment - web-based project. Before I get directly
I just started with creating custom objects in javascript. I want to set this.someObjVar
I have just started looking at javascript so hopefully this will be something simple.
I am quite new to JavaScript and just started some more serious development in
I just started with OOP on Javascript. I am new to programming world. Could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.