Solved

JavaScript createwindow, how to make the window come forward if link is link is clicked again.

Posted on 2004-08-31
1
1,683 Views
Last Modified: 2012-08-13
I use simple Java script to open my secondary or pop-up windows.  When someone clicks on a link the windows opens in front of the parent window.  However if I was to click back on the parent window and select the same link again it will only reload in the background.  Is there a code that can be added to make the window position itself again in the front?


<SCRIPT language="javascript">
<!--

function createWindow(cUrl,cName,cFeatures) {
var xWin = window.open(cUrl,cName,cFeatures)
}
//-->
</SCRIPT>

<a href="javascript:createWindow('/disclaimer.htm','window2','left = 20,top = 20,width=470,height=250,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1')">Click
        here</a>
0
Comment
Question by:Tony-laptops
[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
1 Comment
 
LVL 2

Accepted Solution

by:
dj_jd earned 125 total points
ID: 11946980
Make your window variable global and then focus it:

<SCRIPT language="javascript">
<!--
var xWin;
function createWindow(cUrl,cName,cFeatures) {

if (xWin && !xWin.closed)
    xWin.focus();
else
    xWin = window.open(cUrl,cName,cFeatures)
}
//-->
</SCRIPT>
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

707 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