Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 13th, 2006, 05:28 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript Window Closer

Hi,

I have a javascript that rotates several banner images on my webpage and each image click through to a different webpage. The script is shown below:

<script language="JavaScript" type="text/JavaScript">
<!--
var urlArray = new Array(5);
var banArray = new Array(5);
var counter = 1;
var url = "webpage0.htm"; //initial URL

//add your necessary URL's
urlArray[0] = "webpage0.htm";
urlArray[1] = "webpage1.htm";
urlArray[2] = "webpage2.htm";
urlArray[3] = "webpage3.htm";
urlArray[4] = "webpage4.htm";

if(document.images)
{
  for(i = 0; i < 5; i++)
  {
    banArray[i] = new Image(183, 92);
    banArray[i].src = "banners/" + (i+1) + ".gif";
  }
}


function changeBanner()
{
  if(counter > 4)
   counter = 0;

  document.banner.src = banArray[counter].src;

  url = urlArray[counter];
  counter++;
}

var timer = window.setInterval("changeBanner()", 5000);

//-->
</script>


When one of the images is clicked, the new page opens in a new window. If this new window is then minimised and a different image banner from the original page is clicked, it opens the next new page in the minimised window. I would like the minimised window with the new page in it to maximise (or appear on top as the main window) when a new image is clicked!? Any help would be much apreciated!

regards

Peter
Reply With Quote
  #2 (permalink)  
Old September 13th, 2006, 08:11 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Peter,

Try this:

function changeBanner()
{
  if(counter > 4)
   counter = 0;

  document.banner.src = banArray[counter].src;

  url = urlArray[counter];
  if(window.focus)
  {
  url.focus()
  }
  counter++;
}

This should ensure the new window is on top every time your counter goes round.

HTH
Joe


'sync' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
Reply With Quote
  #3 (permalink)  
Old September 18th, 2006, 06:58 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response, but this stops the image banners from rotating on the initial page.
Reply With Quote
  #4 (permalink)  
Old September 19th, 2006, 07:15 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry Peter, I left out the last line of your code.

function changeBanner()
{
if(counter > 4)
counter = 0;

document.banner.src = banArray[counter].src;

url = urlArray[counter];

        if(window.focus)
        {
        url.focus()
        }

counter++;
}

var timer = window.setInterval("changeBanner()", 5000);

</script>



Cheers
Joe

'sync' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A significant step closer to making TBH modular jimibt BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 October 12th, 2007 04:31 AM
New window not being open by javascript akhilesh_g Classic ASP Professional 1 September 14th, 2007 04:13 AM
Popup window from javascript arnabghosh Javascript How-To 1 March 2nd, 2006 10:17 AM
Popup window from Javascript arnabghosh Javascript 3 March 1st, 2006 01:09 AM
New Window in PHP JavaScript ajutla PHP How-To 2 August 21st, 2004 05:33 PM



All times are GMT -4. The time now is 05:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.