Window Highlighting problem in JavaScript

This is a discussion on "Window Highlighting problem in JavaScript" within the JavaScript Forum section. This forum, and the thread "Window Highlighting problem in JavaScript are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 20th, 2007, 10:15
Junior Member
Join Date: Jun 2007
Location: India
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Window Highlighting problem in JavaScript

I am developing site, which highlight the inactive/Minimized window browser. Please check this coding.


[html]<html>
<head>
<title></title>
</head>
<body>

<A HREF="http://google.com" TARGET="NewTarget" onClick="window.focus() Window.open('http://google.com', 'NewTarget') return false;">
Google</A>
<br/>
<A HREF="http://gmail.com" TARGET="NewTarget" onClick="window.focus() Window.open('http://gmail.com', 'NewTarget') return false;">
Gmail</A>
<br/>
<A HREF="http://answers.google.com" TARGET="NewTarget" onClick="window.focus() Window.open('http://answers.google.com', 'NewTarget') return false;">
Google Answers</A>
<br/>

<A HREF="http://answers.yahoo.com" TARGET="NewTarget" onClick="window.focus() Window.open('http://answers.yahoo.com', 'NewTarget') return false;">
Yahoo Answers</A>
<br/>
<A HREF="http://inbox.com" TARGET="NewTarget" onClick="window.focus() Window.open('http://ginbox.com', 'NewTarget') return false;">
Inbox</A>
<br/>
</body>
</html>
The problem is If i use only one link for a page then it will highlighting the existing inactive window. I am using 4 links in this page, the first link google only highlighting others not reflecting. Please help me to solve this one. If any other method to solve this problem then please provide your code, and your valuable suggestions.
Thanks
Reply With Quote

  #2 (permalink)  
Old Sep 20th, 2007, 11:02
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Window Highlighting problem in JavaScript

So you want to open a new window for each link?

If that is the case, you would need to name each window differently.

eg

Window.open('http://thelinke', 'uniqueName1');
Window.open('http://thelinke', 'uniqueName2');

etc...

I think this is what you mean?

If not let me know in a bit more detail.

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Sep 20th, 2007, 11:17
Junior Member
Join Date: Jun 2007
Location: India
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Window Highlighting problem in JavaScript

Thanks for replying.

Each link should open in a same named target window, thats y i gave the same target name for each link. The problem is
first time if u click any one of the link it will open a new window, after second time it will open the same window, but we dont know whether it is opened or not, so i need to indicate to the user link that named browser blinking in taskbar or appear on the screen. It will help to user to know whether the new link is opened.

the function Window.focus() will help to do this. I tried, but i didn't get result. Please help me..
Thanks
Reply With Quote
  #4 (permalink)  
Old Sep 20th, 2007, 11:34
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Window Highlighting problem in JavaScript

You'd be much better off doing this with a javascript function.

like

Code: Select all

]<html>
<head>
<title></title>

<script type="javascript">
var newWindow = false;

function toggleWindow(url)
{
       // Check if window is or has been open already and make sure it has not been closed
       if (newWindow && newWindow.open && !newWindow.closed)
       {
          // Change the URL and give the window focus
              newWindow.location.href = url;
              newWindow.focus();
       } else {
          // Otherwise open the window and give it focus
          newWindow = window.open(url, 'newWindow');
          newWidnow.focus();
       }
}
</script>
</head>
<body>

<!-- Now put the function call on each linke //-->
<A HREF="http://google.com" TARGET="NewTarget" onClick="toggleWindow('http://google.com') return false;">
Google</A>
<br/>
<A HREF="http://gmail.com" TARGET="NewTarget" onClick="toggleWindow('http://gmail.com') return false;">
Gmail</A>
<br/>
<A HREF="http://answers.google.com" TARGET="NewTarget" onClick="toggleWindow('http://answers.google.com') return false;">
Google Answers</A>
<br/>

<A HREF="http://answers.yahoo.com" TARGET="NewTarget" onClick="toggleWindow('http://answers.yahoo.com') return false;">
Yahoo Answers</A>
<br/>
<A HREF="http://inbox.com" TARGET="NewTarget" onClick="toggleWindow('http://ginbox.com') return false;">
Inbox</A>
<br/>
</body>
</html>
That should give focus to the window each time a link is clicked.

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #5 (permalink)  
Old Sep 20th, 2007, 12:17
Junior Member
Join Date: Jun 2007
Location: India
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Window Highlighting problem in JavaScript

Thanks for send this code.
But code is not focussing the inactive (minimized) window.
Please check this code. I need the output like this
Code: Select all
]
<HTML>
<HEAD>
<TITLE>Window Focus() and Blur()</TITLE>
<SCRIPT LANGUAGE="JavaScript1.1">
// declare global variable name
var newWindow = null
function makeNewWindow() {
    // check if window already exists
    if (!newWindow || newWindow.closed) {
        // store new window object in global variable
        newWindow = window.open("","","width=250,height=250")
        // pause briefly to let IE3 window finish opening
        setTimeout("fillWindow()",100)
    } else {
        // window already exists, so bring it forward
        newWindow.focus()
    }
}
// assemble new content and write to subwindow
function fillWindow() {
    var newContent = "<HTML><HEAD><TITLE>Another Subwindow</TITLE></HEAD>"
    newContent += "<BODY bgColor='salmon'>"
    newContent += "<H1>A Salmon-Colored Subwindow.</H1>"
    newContent += "<FORM><INPUT TYPE='button' VALUE='Bring Main to Front' onClick='self.opener.focus()'>"
    // the following button doesn't work in NN6
    newContent += "<FORM><INPUT TYPE='button' VALUE='Put Me in Back' onClick='self.blur()'>"
    newContent += "</FORM></BODY></HTML>"
    // write HTML to new window document
newWindow.document.write(newContent)
    newWindow.document.close()
}
</SCRIPT>
</HEAD>
<BODY>
<H1>Window focus() and blur() Methods</H1>
<HR>
<FORM>
<INPUT TYPE="button" NAME="newOne" VALUE="Show New Window" onClick="makeNewWindow()">
</FORM>
</BODY>
</HTML>
In this page they are used to open a new window, but i need to use URLs with multiple links. Pleas check it and help me.
Thanks
Reply With Quote
  #6 (permalink)  
Old Sep 20th, 2007, 13:01
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Window Highlighting problem in JavaScript

The function from my last post does the same thing as the code you posted.

The call to newWindow.focus() is the only thing I know and it doesn't work on all browsers/OS etc.

You would be better off closing the window and opening again each time you run the function.

Code: Select all
var newWindow = false;

function toggleWindow(url)
{
       // Close3 the window if its already open.
       if (newWindow && newWindow.open && !newWindow.closed)
       {
          newWindow.close();
} 

          newWindow = window.open(url, 'newWindow');
          newWidnow.focus();
}
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open another new window from javascript window thehermitage JavaScript Forum 10 Jan 27th, 2008 19:42
Need JavaScript for html links should open in a new window in the first time, after.. jayaramgussy JavaScript Forum 0 Jun 19th, 2007 09:00
javascript Window.event help trylah JavaScript Forum 3 Apr 10th, 2007 13:31
javascript to open new window snappy JavaScript Forum 4 Nov 9th, 2006 13:02
Javascript popup window with ASP madhuri.t Classic ASP 0 May 3rd, 2006 10:42


All times are GMT. The time now is 22:29.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43