Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Bringing target windows to front...

Posted on 2007-04-09
6
Medium Priority
?
242 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

609 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