PDA

View Full Version : one link opening multiple (new) windows


fmh002
04-04-2004, 11:03 AM
hello

i want to be able to open 4 websites by a single click on a webpage.

i know javascript can do that but what i lack is code.

i need your help

peace

fyrye
04-14-2004, 11:44 PM
Build a function with the window.open command for each site you want a new window for, then in your hyperlink execute the function

<Script Language="javascript">
function NewWindows()
{
window.open(URL')
window.open(URL')
window.open(URL')
window.open(URL')
}
</Script>

<a href="NewWindows();">

fmh002
04-15-2004, 02:10 AM
whats wrong with it?


<html>
<head>
<Script Language="javascript">
function NewWindows()
{
window.open("www.javascriptsource.com")
window.open("www.javascriptsource.com")
window.open("www.javascriptsource.com")
window.open("www.javascriptsource.com")
}
</Script>
</head>
<body>
<a href="NewWindows();">
<p>link
</body>
</html>

fyrye
04-15-2004, 02:59 AM
Sorry thought you knew basic HTML


<html>
<head>
<Script Language="javascript">
function NewWindows()
{
window.open("http://www.javascriptsource.com")
window.open("http://www.javascriptsource.com")
window.open("http://www.javascriptsource.com")
window.open("http://www.javascriptsource.com")
}
</Script>
</head>
<body>
<a href="#" onclick="NewWindows();">link</a>
</body>
</html>

fmh002
04-15-2004, 03:07 AM
yup not even the basics... :sick:

thnx for the code... i also wanted to know how i could get the new windows maximised when they pop up... currently they are not maximised and are located randomly across the screen.

could you help me with that too? ;)

fyrye
04-17-2004, 07:46 PM
http://msdn.microsoft.com

Look for window.open in the technical articles.
One of the pages should say something similar to DHTML / Javascript Refrence or Window Object / Methods / Events / Properties

You'll get alot more out of that site, than hitting up the forums.
Here is an example of I think all of the possible window.open properties if you want one enabled just delete the =0 part.
In the case of top, left, width, and hieght these are relative sizes
I dont have the maximize code on hand but i believe this has to be done on the body tag of the loaded window. The fullscreen property is the same as if you hit F11 on your ketboard. Press it again to make it normal, and the size of the window is ignored in IE6.0

window.open('http://url','EachWindowName', 'resizable=0, channelmode=0, directories=0, titlebar=0, top=0, left=0, width=1, height=1, fullscreen=0, scrollbars=0').focus();void(0)


Make sure you name the "EachWindowName" differently for each window or it will just load the last one called
for example
WindowName0
WindowName1
WindowName2

if you do another WindowName0 the first one will be taken over by the latest.

*Note Sorry for any mix up, I did the double click type routine i use in html docs, and it deleted my ' marks

fmh002
04-18-2004, 01:51 PM
thnx mate

fyrye
04-18-2004, 08:22 PM
I did leave some out of that sorry.
Here are the rest simply add after , scrollbars=0


,menubar=0, status=0, toolbar=0


*Edit*
Also for refrence sake if you should want them to load behind your current page add
self.focus(); at the bottom of your popups
this will also work on hyperlinks if you dont want web spider search engines to follow your links

<a onclick="window.open('YourURL','Title',', titlebar=0 ,resizable=0, width=500, height=250, fullscreen=0, scrollbars=0, menubar=0, status=0, toolbar=0'); self.focus();">text</a>