|
|
 |
January 23rd, 2008, 08:39 AM
|
#1
|
|
New Member
Join Date: Jan 2008
Location: scotland
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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>
<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; January 23rd, 2008 at 09:31 AM..
Reason: please use [HTML] tags when posting HTML
|
|
|
January 23rd, 2008, 09:26 AM
|
#2
|
|
Most Reputable Member
Join Date: Mar 2004
Location: Good Ol'London
Age: 24
Posts: 1,683
Thanks: 1
Thanked 4 Times in 4 Posts
Rep Altering Power: 0
|
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>
|
|
|
January 23rd, 2008, 11:09 AM
|
#3
|
|
New Member
Join Date: Jan 2008
Location: scotland
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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? 
|
|
|
January 23rd, 2008, 11:20 AM
|
#4
|
|
Most Reputable Member
Join Date: Mar 2004
Location: Good Ol'London
Age: 24
Posts: 1,683
Thanks: 1
Thanked 4 Times in 4 Posts
Rep Altering Power: 0
|
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.
|
|
|
January 23rd, 2008, 03:57 PM
|
#5
|
|
New Member
Join Date: Jan 2008
Location: scotland
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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
|
|
|
January 24th, 2008, 07:25 AM
|
#6
|
|
Most Reputable Member
Join Date: Mar 2004
Location: Good Ol'London
Age: 24
Posts: 1,683
Thanks: 1
Thanked 4 Times in 4 Posts
Rep Altering Power: 0
|
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...
|
|
|
January 25th, 2008, 06:23 PM
|
#7
|
|
New Member
Join Date: Jan 2008
Location: scotland
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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
|
|
|
January 25th, 2008, 10:15 PM
|
#8
|
|
Most Reputable Member
Join Date: Mar 2004
Location: Good Ol'London
Age: 24
Posts: 1,683
Thanks: 1
Thanked 4 Times in 4 Posts
Rep Altering Power: 0
|
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.
|
|
|
January 27th, 2008, 11:45 AM
|
#9
|
|
New Member
Join Date: Jan 2008
Location: scotland
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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; January 27th, 2008 at 11:47 AM..
|
|
|
January 27th, 2008, 11:59 AM
|
#10
|
|
Most Reputable Member
Join Date: Mar 2004
Location: Good Ol'London
Age: 24
Posts: 1,683
Thanks: 1
Thanked 4 Times in 4 Posts
Rep Altering Power: 0
|
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...
|
|
|
January 27th, 2008, 04:42 PM
|
#11
|
|
New Member
Join Date: Jan 2008
Location: scotland
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|