javascript to open new window

This is a discussion on "javascript to open new window" within the JavaScript Forum section. This forum, and the thread "javascript to open new window 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 Nov 3rd, 2006, 17:58
Up'n'Coming Member
Join Date: Mar 2006
Location: UK
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
javascript to open new window

In trying to avoid the "target" issue, I have reverted to javascript to create a new browser window for certain links on my site. I am trying to keep it working when javascript is disabled and that seems to be okay in Firefox so far. For accessibility reasons I'm including alt text "opens in new window" too.

IE on PC: alt says "opens in new window" and then it doesn't, it opens in the same window
IE on PC: alt says "opens in new window" and new window opens....but no content.

Firefox on PC: alt says "opens in new window" and does just that. However if I go back to the main window and click on another link to open in the new window, the new window hides behind the main window.
Firefox on the mac: as above

I can live with it opening in the same window, but it's confusing then as my alt text says "opens in new window".

Can anyone troubleshoot my basic code below. I'm sure I'm making a fundamental error...should I start from scratch again?
HTML: Select all
<a href="abercorris.html" onclick="window.open(this.href,'standard','height=550,width=780,menubar,scrollbars,resizable,toolbar'); return false" title="Opens in a new window">Abercorris</a>

Last edited by snappy; Nov 3rd, 2006 at 18:03. Reason: duplicate thread title
Reply With Quote

  #2 (permalink)  
Old Nov 6th, 2006, 09:05
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: javascript to open new window

Unobtrusive JavaScript is the only way to fly:

http://adactio.com/atmedia2005/

That's suited to exactly what you need.
Reply With Quote
  #3 (permalink)  
Old Nov 6th, 2006, 20:16
Up'n'Coming Member
Join Date: Mar 2006
Location: UK
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Re: javascript to open new window

That sounds cool...... and.... complicated!
DOM scripting is something I planned on looking at when I covered CSS and PHP and MySQL and the secrets of the universe/meaning of life etc.

I'm not afraid of learning, but be honest with me, is this worth a non-techie newbie pursuing? Or should I take the flak and keep my "target"s??

Cheers
Snappy
Reply With Quote
  #4 (permalink)  
Old Nov 8th, 2006, 09:50
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: javascript to open new window

Everything you need is in that link I posted...

Just add that JavaScript to your page and add the class "popup" to every link you want to open in a new window.

IE

Code: Select all
<html>
    <head>
        <script type="text/javascript" src="popup.js"></script>
    </head>
    <body>
        <a href="http://google.com/" class="popup">Google</a>
    </body>
</html>
Reply With Quote
  #5 (permalink)  
Old Nov 9th, 2006, 13:02
Up'n'Coming Member
Join Date: Mar 2006
Location: UK
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Re: javascript to open new window

I've done exactly as you say, but doesn't work for me. Link opens in the same window. Should I be putting something inside the <script></script> tags?

Code: Select all
<a href="new.html/" class="popup">new</a>
Using the code from the link you included which is pretty much what I was doing already..
Code: Select all
<a href="new.html" onclick="window.open(this.href); return false"">new</a> <br />
the link opens in a new window.

However if I go back to the main window and click on another link to open in the new window, the new window is hidden behind the main window. I have a list of 30 links that I want to open in this new window and displayed on top of the main window obviously. How can I make the pop up come to the front every time?
Reply With Quote
Reply

Tags
javascript, accessibility, open window

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
Change open in new window to open in same window nsr500rossi JavaScript Forum 2 Jan 18th, 2008 14:13
[SOLVED] open new window from main window AdRock Other Programming Languages 1 Nov 1st, 2007 02:45
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
Open a new window pokerskatershark JavaScript Forum 4 Mar 17th, 2006 19:25


All times are GMT. The time now is 19:05.


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