PDA

View Full Version : Multiple New window


8mycsh
11-07-2002, 06:12 PM
I want to have 2 links to use the function newWindow.

This is the coding I used on one page because I only needed to open 1 new window

-------------------------------
function newWindow(){
open('http://www.thissite.com/rules.htm', 'rules', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=688,height=300')}
-------------------------------


How do I modify this so I can have 2 links. 1 attached to the coding above, and another to do the same as above but open form.htm in a new window

Borgtex
11-07-2002, 06:35 PM
Welcome to the fascinating world of parameters ;) :

function newWindow(url){
open(url, 'rules', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=688,height=300')}


and then, when you call it:

newWindow('http://www.thissite.com/rules.htm')
or
newWindow('http://www.thissite.com/form.htm')
or
newWindow('http://www.thissite.com/anything.htm')


add more parameters and you will be able to specify diferent heights and widths for every new window.

Simrey
11-07-2002, 06:38 PM
Thus:

-------------------------------
function newWindow(){
return window.open('', 'rules', 'toolbar=no,location=no,directories=no,status=no,m
enubar=no,resizable=no,width=688,height=300')}
-------------------------------

Then for your links

<a href="http://www.thissite.com/rules.htm" onClick="newWindow" target="rules">This site</a>

<a href="form.htm" onClick="newWindow" target="rules">Form</a>


That's one way anyway...

beetle
11-07-2002, 06:42 PM
Better to have links that degrade or function with javascript off, and are more search-engine-spider friendly IMHO :D Use Borgtex's version of the function, and call your popups like this...

<a href="http://www.thissite.com/rules.htm" onClick="newWindow(this.href); return false;">Link</a>

Simrey
11-07-2002, 06:56 PM
sorry -- or course that shld be onclick="newWindow()" both times

8mycsh
11-08-2002, 10:46 AM
I am still having difficult with this.

here's my coding at the top of the page:

Link #1
------------------------
function newWindow('http://www.thisite.com/rules.htm'){
open('www.thisite.com/rules.htm', 'rules', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=688,height=300')}
------------------------

Link#2
------------------------
function newWindow('http://www.thissite.com/things.htm'){
open('www.thissite.com/things.htm', 'rules', 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=688,height=300')}



And then this is the actual link in the page:
-------------------------
Click <font color="#8C96A2"><a href="javascript:newWindow('http://www.thisite.com/rules.htm')">here</a></font>
to see the rules.

glenngv
11-08-2002, 11:34 AM
there should only one function

function newWindow(url,target){
window.open(url,target, 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width=688,height=300');
}

...

Click <font color="#8C96A2"><a href="http://www.thisite.com/rules.htm" target="rules" onclick="newWindow(this.href,this.target);return false;">here</a></font>
to see the rules.

Click <font color="#8C96A2"><a href="http://www.thisite.com/things.htm" target="things" onclick="newWindow(this.href,this.target);return false;">here</a></font>
to see the things.

8mycsh
11-08-2002, 08:31 PM
Ok I have gotten it all straight now....I have another question reguarding this code. I have a drop down menu and I want to use the code to pull up a new window. Here is what I have for the code....it won't work so I must be doing something wrong or missing something can you take a look and see what it might be.

--------------------------------------
<option value="a href=http://www.thissite.com/rules.htm" target="rules" onClick="newWindow(this.href,this.target);return false;">Appointments</option>
--------------------------------------



Thanks

Borgtex
11-08-2002, 11:42 PM
Oh no! :) you messed forms and links.

Something like this should work:

<form name="form1">
<select name="menu1" onChange="newWindow(this.options[this.selectedIndex].value,'')">
<option value="page1.htm" selected>page1</option>
<option value="page2.htm">page2</option>
</select>
</form>


I really recommend you to take a good HTML & javascript reference to have a good basis.