?
Solved

Bringing target windows to front...

Posted on 2007-04-09
6
Medium Priority
?
244 Views
Last Modified: 2010-04-09
I have decided to try to teach myself some basic html through a project I can use rather than through abstrat "hello world" examples. The idea of my newest project is to have an small "control panel" windows with my favourite links. This part is easy. Basically it is all a matter of the name of the window to be controlled. So, pressing the link

<a href="http://www.yahoo.dk" target="otherwindow">Click Here</a>
in one window will cause yahoo to open in a new window (unless the window named "otherwindow" is already opened; then it will just change the contents of it). Now, the trouble is that it is only when a new window is opened from the "controller window", it is set to be active. When you change the content by pressing another link (or the same link for that matter) the controller window stays in the front, whereas the controlled window stays in the back.

What I am after is - in other words - a way to change the content in the controlled window and, at the same time force the controlled window to the front.

Help will be appreciated!

plovfure  

0
Comment
Question by:plovfure
  • 3
  • 2
6 Comments
 
LVL 10

Expert Comment

by:Jaax
ID: 18874841
Instead of opening the page from href, open it from a function called from hyperlink

<a href="#" onlick="openWindow(http://'www.yahoo.com')"> Click Here</a>

In your script tag define a function
<scriipt>
function openWindow(url){
   winHan = window.open(url, "othertarget");
   if(winHan){
       winHan.focus();
   }
}

</script>
0
 

Author Comment

by:plovfure
ID: 18874948
Thanks, but I am not completely sure that I got it right.  This is my small "control panel":
<html>
<head>
<script>
function openWindow(url){
   winHan = window.open (url, "othertarget");
   if(winHan){
       winHan.focus();
   }
}

</script>

</head>
<a href="#" onlick="openWindow(http://www.yahoo.com)"> Click Here</a>
</html>

I do not exactly understand the workings of the script, but I reckon that what it does is to proces the webaddress after the openwindow () to open it in the target window called "othertarget". But the above code does mot work for me. I also tried to have the script outside the head, but in both instances nothing happens.

Thanks, LP
0
 

Author Comment

by:plovfure
ID: 18874950
And thanks for your help by the way
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Expert Comment

by:Jaax
ID: 18874971
onlick="openWindow('http://www.yahoo.com')">
Note that the url is embedded within a single quote. Hope you didn't miss it.
0
 
LVL 10

Accepted Solution

by:
Jaax earned 1000 total points
ID: 18874994
Sorry! there was a typo error and also the anchor needs to be placed within the body tag.
Also made some minor changes. This code does work :

<html>
<head>
      <script>
      function openWindow(url){
         winHan = window.open (url, "othertarget");
         if(winHan){
               winHan.focus();
         }
      }

      </script>
</head>

<body>
      <a href="#" onclick="openWindow('http://www.yahoo.com'); return false"> Click Here</a>
</body>
</html>
0
 
LVL 4

Expert Comment

by:cheesygit182
ID: 18875226
Hi, try this:

<html>
<head>

<script language="javascript" type="text/javascript">
<!--
function popupandfocus(url){
newwindow = window.open (url,'name');// create a new window(popup) stored in a variable called "newwindow"
if (window.focus) {newwindow.focus()}// if the browser supports focusing popups, give the "newwindow" focus(bring it to front)
return false;// stops the "control window" from changing it's url to "controlwindow.html#". check it out here: http://cs.wellesley.edu/~cs110/examples/return.html
}
// -->
</script>

</head>
<body>
Click <a href="http://www.yahoo.com" target="_blank">Here</a> to open a normal popup window with yahoo.com inside, using plain old html.<br>
Click <a href="http://www.yahoo.com" onclick="return popupandfocus('http://www.yahoo.com')">Here</a> to open a popup window with yahoo.com inside, and focus it, using javascript.<br>
Click <a href="http://www.google.com" onclick="return popupandfocus('http://www.google.com')">Here</a> to change the content of the popup window to google.com, and focus it, using javascript.<br>
</body>
</html>

If you would like to know more about how it works, just ask.

~cheesygit182
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Suggested Courses

862 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