Target Window Name

This is a discussion on "Target Window Name" within the Web Page Design section. This forum, and the thread "Target Window Name are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 18th, 2007, 11:52
Junior Member
Join Date: Jun 2007
Location: India
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Target Window Name

In My HTML page, the link first time should be opening in a new window (Target name="JaiInfo"), Next time onwards (Page contain several links, the rest of links are open in the existing Window) Other links should be open in the same target name.
Please help me to solve this problem.
Reply With Quote

  #2 (permalink)  
Old Sep 18th, 2007, 12:03
SuperMember

SuperMember
Join Date: Sep 2006
Location: Pink House
Posts: 3,946
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Target Window Name

How is the page designed?
Frames?
XHTML/Css?
Reply With Quote
  #3 (permalink)  
Old Sep 18th, 2007, 15:47
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Target Window Name

Please read this The Forumz's guide to posting

Last edited by karinne; Sep 18th, 2007 at 15:55. Reason: It's the forumz guide really ;)
Reply With Quote
  #4 (permalink)  
Old Sep 18th, 2007, 15:51
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Target Window Name

Quote:
Originally Posted by jayaramgussy View Post
In My HTML page, the link first time should be opening in a new window (Target name="JaiInfo"), Next time onwards (Page contain several links, the rest of links are open in the existing Window) Other links should be open in the same target name.
Please help me to solve this problem.
the target for a new window is _blank
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #5 (permalink)  
Old Sep 18th, 2007, 16:00
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Target Window Name

Isnt _blank depreciated and therefore will make your code invalid?
Reply With Quote
  #6 (permalink)  
Old Sep 18th, 2007, 16:01
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Target Window Name

The target attribute is deprecated actually
Reply With Quote
  #7 (permalink)  
Old Sep 18th, 2007, 16:07
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,649
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Target Window Name

I knew something to do with that was depreciated
Reply With Quote
  #8 (permalink)  
Old Sep 18th, 2007, 16:07
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Target Window Name

It's been a while since I've used frames/targets etc.
so sorry
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #9 (permalink)  
Old Sep 19th, 2007, 12:41
Junior Member
Join Date: Jun 2007
Location: India
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Target Window Name

HTML: Select all
<HTML>
<body>
<A HREF="http://www.google.com" TARGET="Jai"
onClick="Window.open('http://www.google.com', 'Jai', 'status'); return false">Google</A><br/>
<A HREF="http://www.inbox.com" TARGET="Jai"
onClick="window.open('http://www.inbox.com', 'Jai', 'status'); return false">
Inbox</A><br/>
<A HREF="http://www.hotmail.com" TARGET="Jai"
onClick="window.open('http://www.hotmail.com', 'Jai', 'status'); return false">
Hotmail</A><br/>
<A HREF="http://www.yahoo.com" TARGET="Jai"
onClick="window.open('http://www.yahoo.com', 'Jai', 'status'); return false">
Yahoo</A><br/>
<br/>
</body>
</html>
This is the code. Its working fine. But the problem is, first time if click on any one link in this html will open a new window, then if u minished that opened window and again you click on the other link it will open the existing Window (target="Jai"). But i didn't get any indication that the Jai Screen had changed. I need to resurface that window (I dont need the alert message). that window just refresh and show to the user.
Please help me

Last edited by karinne; Sep 19th, 2007 at 12:52. Reason: Please use the vBcode [ html ] when inserting HTML code in your post.
Reply With Quote
  #10 (permalink)  
Old Sep 20th, 2007, 22:44
New Member
Join Date: Apr 2007
Location: UK
Age: 21
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Target Window Name

Because you are returning false in the onClick handler the href and target attributes have no effect on what happens when you click on the link. To use those attributes properly do this

Code: Select all
<script type="text/javascript">
var my_window = null;

function focusWindow() {
    if ( my_window == null )
        my_window = window.open( "", "Jai", "status" );
    my_window.focus();
}
</script>

<a href="http://www.google.com" target="Jai" onclick="focusWindow();">Google</a>
<a href="http://www.yahoo.com" target="Jai" onclick="focusWindow();">Yahoo</a>
But since it seems like the target attribute is deprecated then here is a better way:

Code: Select all
<script type="text/javascript">
window.onload = function() {
    var specialLinks = document.getElementsByTagName("a");
    for ( i = 0; i < specialLinks.length; i++ ) {
        if ( specialLinks[i].className == "specialLink" ) {
            specialLinks[i].onclick = function() {
                updateWindow(this.href);
                return false;
            };
        }
    }
};
var my_window = null;
function updateWindow( href ) {
    if ( my_window == null )
        my_window = window.open( href, 'Jai', 'status' );
    else
        my_window.location = href;
    my_window.focus();
}
</script>
<a href="http://www.google.com/" class="specialLink">Google</a>
<a href="http://www.yahoo.com/" class="specialLink">Yahoo</a>
Or, you could manually add the onClick handler that does updateWindow() for each <a> tag if there isn't that many.
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
[SOLVED] open new window from main window AdRock Other Programming Languages 1 Nov 1st, 2007 02:45
Target _blank Jack Franklin Web Page Design 12 Oct 12th, 2007 09:55
XHTML Target JacobHaug Web Page Design 7 Jan 4th, 2007 11:55
Save Target As VanderBOOM JavaScript Forum 4 Dec 15th, 2005 10:25
Frameset target help please charter Flash & Multimedia Forum 4 Mar 28th, 2004 10:05


All times are GMT. The time now is 23:48.


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