Open another new window from javascript window

This is a discussion on "Open another new window from javascript window" within the JavaScript Forum section. This forum, and the thread "Open another new window from javascript 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 Jan 23rd, 2008, 11:39
New Member
Join Date: Jan 2008
Location: scotland
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Open another new window from javascript window

Hello folks.. I am a newcomer with a little question that I'd be grateful for some help with...
I'm not a professional web developer at all and am just learning bit by bit whilst making my own sites by nicking code from here and there... so bear with me...

Anyway, I have made a page with click links on an image map that open up a new little pop up window of certain dimensions etc with javascript... as below (with imaginary urls )
HTML: Select all
<html>

<head>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script language="javascript" type="text/javascript">
function winOpen(goto){
window.open(goto,null,"height=570,width=450,status=yes,toolbar=no,menubar=no,scrollbars=no,resizable=no,top=80,left=80");
}
</script>
<title>:: title here ::</title>
</head>



<p align="center">
<img border="0" src="http://www.myimaginarysite.com/images/exampleimage.jpg" width="849" height="910" usemap="#MapTest"></p>


<map name="MapTest">
<area shape="rect" coords="431, 81, 468, 102" href="javascript:winOpen('http://www.myimaginarysite.com/popupexample.htm')" title=":: example ::" alt="example">
</map>

</body>

</html>
My question is this ...
Can I use a similar javascript function in the html file for the new little window (http://www.myimaginarysite.com/popupexample.htm) ?

The reason I want to do this is that this little page will include links to external websites and I would like them to open in a separate window altogether from those already open.. Ideally a larger window over to the right of the little popup window.

I have tried repeating the code above within the small popup's html but it appears not to work... the link just opens in the small window. Perhaps there is some difficulty with "doubling" the javascript?

Hope I have explained clearly... and that someone might be able to help.

Many thanks

Rima

Last edited by c010depunkk; Jan 23rd, 2008 at 12:31. Reason: please use [HTML] tags when posting HTML
Reply With Quote

  #2 (permalink)  
Old Jan 23rd, 2008, 12:26
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Open another new window from javascript window

You don;t need javascript, just add target="_blank" to your links.
eg.:
<a href="http://www.webforumz.com/" target="_blank">Go to Webforumz.com</a>
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #3 (permalink)  
Old Jan 23rd, 2008, 14:09
New Member
Join Date: Jan 2008
Location: scotland
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open another new window from javascript window

Thanks spinal007 I tried this already ... but it only opens a second browser tab in the first little popup window... not really what I am after.
I want to be able to specify the position and dimensions of the second popup that opens separate from the first. Is this possible?
Reply With Quote
  #4 (permalink)  
Old Jan 23rd, 2008, 14:20
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Open another new window from javascript window

of course it is, just use the same code you already have on the first page:
<script language="javascript" type="text/javascript">
function winOpen(goto){
window.open(goto,null,"height=570,width=450,status =yes,toolbar=no,menubar=no,scrollbars=no,resizable =no,top=80,left=80");
}
</script>...and...

<a href="javascript:winOpen('http://www.webforumz.com/');">Webforumz</a>

...change..
height=570,width=450,
...to whatever you like.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #5 (permalink)  
Old Jan 23rd, 2008, 18:57
New Member
Join Date: Jan 2008
Location: scotland
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open another new window from javascript window

yes this is what I tried.. but for some reason it does not work ... the new page just opens in the same window despite the new javascript command for it to open in a new window...

Have a look here : www.orlawren.com ... the link I have made is from my name "rima staines" ... about halfway down the second photograph ...
this opens up a new window ... all fine ... and then the links within that window should open another.. but I am finding that it doesn't ... any brainwaves? cheers
Reply With Quote
  #6 (permalink)  
Old Jan 24th, 2008, 10:25
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Open another new window from javascript window

Ok, find this code:
window.open(goto,null,

on the first page, change it to:
window.open(goto,'MyPopup',

on the second page (the popup), change it to:
window.open(goto,'MyPopup' + (window.count = (window.count || 0 ) +1),

See if that works...
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #7 (permalink)  
Old Jan 25th, 2008, 21:23
New Member
Join Date: Jan 2008
Location: scotland
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open another new window from javascript window

Hooray it works! That's fantastic! Many thanks indeed ...
perhaps one day I might know what on earth all that means!
Cheers

Rima
Reply With Quote
  #8 (permalink)  
Old Jan 26th, 2008, 01:15
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Open another new window from javascript window

lol, it's simple - window.open takes 3 parameters: url, window name, window settings.
the 'window name' parameter lets you identify the window and re-use it.
all you had to do was use a different 'window name' every time a link was clicked.
this...
(window.count = (window.count || 0 ) +1)
...was just a clever little way of doing just that. it will add an increment (1,2,3,4,5...) to the name of the popup every time you click on a link, so the name is never the same, so you get a new window every time.

You'll get there with a little practice...

PS.: For a real explanation of window.open, see this and maybe these.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #9 (permalink)  
Old Jan 27th, 2008, 14:45
New Member
Join Date: Jan 2008
Location: scotland
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open another new window from javascript window

Thanks I'll get there slowly ...

Here's another little problem for you
From the main 1st page (www.orlawren.com) All the little popup windows that open are using the same function and therefore open at the same size ....
If you look to the bottom of the page ..the old postcard is a click link to a small window containing a guestbook (which as you can see is too large for the window )
is it possible to open them at different sizes using the code you gave me? Do I have to repeat the script function within the html for that page each time with a different number?
Thanks again .. help much appreciated

Last edited by thehermitage; Jan 27th, 2008 at 14:47.
Reply With Quote
  #10 (permalink)  
Old Jan 27th, 2008, 14:59
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Re: Open another new window from javascript window

like I said before, change...
height=570,width=450,
...to whatever value you like the window to be.

I suggest you read the window.open specs if you're going to be using it so often...
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote
  #11 (permalink)  
Old Jan 27th, 2008, 19:42
New Member
Join Date: Jan 2008
Location: scotland
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open another new window from javascript window

I worked it out! The problem I had was not knowing that you could name the functions differently eg winOpen and winOpen2 therefore enabling me to make the different windows do different things!
cheers
Rima
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
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
javascript to open new window snappy JavaScript Forum 4 Nov 9th, 2006 13:02
Open a new window pokerskatershark JavaScript Forum 4 Mar 17th, 2006 19:25


All times are GMT. The time now is 04:41.


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