{"id":7845,"date":"2021-08-12T12:23:47","date_gmt":"2021-08-12T12:23:47","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=7845"},"modified":"2022-04-13T16:30:45","modified_gmt":"2022-04-13T16:30:45","slug":"moving-windows-in-javascript","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/","title":{"rendered":"Moving Windows in JavaScript"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Moving Windows<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">moveBy ( ) \u2013 This method moves the current window by a specified amount of pixels.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:- window.moveBy(horizontalPixels, verticalPixels);<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">window \u2013 It is the name of the window to move or is called just window if it is the main window.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">horizontalPixels \u2013 It is the number of horizontal pixels to move the window where positive numbers move the window to the right and negative numbers to the left.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">verticalPixels \u2013 It is the number of vertical pixels to move the window where positive number move the window down and negative number up.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ex:- newWindow.moveBy(200, 200);<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Moving Windows<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">moveTo ( ) \u2013 This method moves the window to the specified coordinates.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:- window.moveTo(x, y);<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">window \u2013 It is the name of the window to move or is called just window if it is the main window.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">x \u2013 It is the screen co-ordinate on the x-axis to move the window to.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">y \u2013 It is the screen co-ordinate on the y-axis to move the window to.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ex:- newWindow.moveTo(200, 200);<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Resizing Windows<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Resizing Windows<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">resizeBy ( ) \u2013 This method is used to resize the current window by a certain amount, relative to its current size.\u00a0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:- window.resizeBy(width, height);<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">window \u2013 It is the name of the window to move or is called just window if it is the main window.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">width \u2013 It is the number of width pixels, where positive numbers increase the window and negative numbers decrease.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">height \u2013 It is the number of height pixels, where positive numbers increase the window and negative numbers decrease.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ex:- newWindow.resizeBy(200, 200);<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Resizing Windows<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">resizeTo ( ) \u2013 This method is used to resize a window to the specified width and height.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:- window.resizeTo(width, height);<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">window \u2013 It is the name of the window to move or is called just window if it is the main window.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">width \u2013 It is an integer representing the new outerWidth in pixels (including scroll bars, title bars, etc).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">height \u2013 It is an integer value representing the new outerHeight in pixels (including scroll bars, title bars, etc).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ex:- newWindow.resizeTo(200, 200);<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Scrolling Windows<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">scrollBy ( ) \u2013 This method scrolls the document in the window by the given amount.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax:- window.scrollBy(x, y); or window.scrollBy(options);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">window \u2013 It is the name of the window to scroll or is called just window if it is the main window.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">x \u2013 How many pixels to scroll by, along the x-axis (horizontal). Positive values will scroll to the right, while negative values will scroll to the left<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">y \u2013 How many pixels to scroll by, along the y-axis (vertical). Positive values will scroll down, while negative values scroll up<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Options \u2013 It is an object with three possible properties:<br>                top, which is the same as the y-coord<br>                left, which is the same as the x-coord<br>                behavior, which is a string containing one of smooth, instant, or auto; default is auto<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/80f98b46e82513b83ca74a15de75ec7a.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\">Note &#8211; For this method to work, the visible property of the window&#8217;s scrollbar must be set to true!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Scrolling Windows<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">scrollTo ( ) \u2013 This method scrolls to a particular set of coordinates in the document.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax:- window.scrollTo(x, y); or window.scrollTo(options);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">window \u2013 It is the name of the window to scroll or is called just window if it is the main window.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">x \u2013 It is the pixel along the horizontal axis of the document that you want to be displayed in the upper left.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">y \u2013 It is the pixel along the vertical axis of the document that you want to be displayed in the upper left.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">options is an object with three possible properties:<br>            top, which is the same as the y-coord<br>            left, which is the same as the x-coord<br>            behavior, which is a string containing either smooth, instant, or auto; default is auto<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/86c5458e800c2bb297f2e77f7c77afe0.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>Moving Windows moveBy ( ) \u2013 This method moves the current window by a specified amount of pixels. Syntax:- window.moveBy(horizontalPixels, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[16],"tags":[5095,4240,6247,6248,6249],"class_list":["post-7845","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript","tag-method","tag-moving-windows","tag-resizing-windows","tag-scrolling-windows"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Moving Windows in JavaScript - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Moving Windows in JavaScript - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Moving Windows moveBy ( ) \u2013 This method moves the current window by a specified amount of pixels. Syntax:- window.moveBy(horizontalPixels, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-12T12:23:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-13T16:30:45+00:00\" \/>\n<meta name=\"author\" content=\"rajeshkumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rajeshkumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/\"},\"author\":{\"name\":\"rajeshkumar\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"headline\":\"Moving Windows in JavaScript\",\"datePublished\":\"2021-08-12T12:23:47+00:00\",\"dateModified\":\"2022-04-13T16:30:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/\"},\"wordCount\":631,\"commentCount\":0,\"keywords\":[\"Javascript\",\"Method\",\"Moving Windows\",\"Resizing Windows\",\"Scrolling Windows\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/\",\"name\":\"Moving Windows in JavaScript - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2021-08-12T12:23:47+00:00\",\"dateModified\":\"2022-04-13T16:30:45+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/moving-windows-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Moving Windows in JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\",\"name\":\"rajeshkumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"caption\":\"rajeshkumar\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/rajeshkumar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Moving Windows in JavaScript - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Moving Windows in JavaScript - scmGalaxy","og_description":"Moving Windows moveBy ( ) \u2013 This method moves the current window by a specified amount of pixels. Syntax:- window.moveBy(horizontalPixels, [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/","og_site_name":"scmGalaxy","article_published_time":"2021-08-12T12:23:47+00:00","article_modified_time":"2022-04-13T16:30:45+00:00","author":"rajeshkumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rajeshkumar","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/"},"author":{"name":"rajeshkumar","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"headline":"Moving Windows in JavaScript","datePublished":"2021-08-12T12:23:47+00:00","dateModified":"2022-04-13T16:30:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/"},"wordCount":631,"commentCount":0,"keywords":["Javascript","Method","Moving Windows","Resizing Windows","Scrolling Windows"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/","name":"Moving Windows in JavaScript - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2021-08-12T12:23:47+00:00","dateModified":"2022-04-13T16:30:45+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/moving-windows-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Moving Windows in JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361","name":"rajeshkumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","caption":"rajeshkumar"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/rajeshkumar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=7845"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7845\/revisions"}],"predecessor-version":[{"id":7848,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7845\/revisions\/7848"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=7845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=7845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=7845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}