- HubPages»
- Technology»
- Computers & Software»
- Computer Science & Programming»
- Programming Languages
Javascript: How to refresh parent window from a pop-up after closing pop-up
Description of javascript sample
Recently, I wrote a hub for creating a pop-up html window from a link. This article is a companion to that one. There have been times, that I gave the user a pop-up javascript window to edit or add to what they were already looking at. Maybe, there's an update to a database or an upload of an image, etc.
So, the user clicks the pop-up window link, makes the update or does whatever, and you want them to click the "close window" link, which will close the pop-up and refresh the parent window displaying the new data, images, etc., that they user just completed from the pop-up. Rather than the user having to use the refresh option of the browser. It just makes it a better user experience online. One less step for them to worry about.
Sample Javascript
Place the following javascript code between the <HEAD></HEAD> tag of your <HTML> page.
<SCRIPT language=JavaScript> <!-- function win(){ window.opener.location.href="http://www.yoursite.com/parentwindowpage.html"; self.close(); //--> } </SCRIPT>
Sample HTML code for Close Button
Below is the sample HTML code for a close button on your page to close the pop-up window, and refresh the parent window.
<input type=button onClick="win();" value="Close This Window" style="FONT-SIZE: 10px">
- Javascript: Pop-up window from a HTML link
- Javascript: How to create a simple slide show with clickable links
- Javascript: Pop up Message Box On Submit
- Javascript: How to disable Right Click option
- Javascript: Controlling the number of characters entered into a HTML form field.
- Javascript: Rotate a different image when the page is reloaded
- Javascript: Drop Down Menu List
- Javascript: A simple calendar with today's date highlighted.
- Javascript: How to hide and show other form fields with a select box with Javascript and HTML