james said:
I have multiple javascript links ( Small informational popups )
How can i get a separete js script to work with the links or do i keep
adding separate scripts into the page for every link
http://www.flexworkout.com/contact.htm
please view the source on the links and youll see what i mean
this cant be right?
I guess you are talking about these
<td width="99%" height="18"><b>
<font size="1" color="#FF6600" face="Tahoma">
<a title="Click To Learn About Andrea" href="javascript

op_winG1();">
<font color="#FF6600">GENERAL MANAGER / ANDREA</font></a></a><a
title="Click To Learn About Andrea" href="javascript

op_winG1();"><font
color="#FF6600">
</font>
</a></font><font size="1" color="#FF6600">
</a></font></font></td>
This calls pop_winG1
G1 = "";
function pop_winG1(psjs_url){
if(G1){
if(G1.closed){
G1 = window.open("
http://www.flexworkout.com/staff_1.htm", "G1",
"top=50,left=50,width=400,height=480,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0")
} else {
G1.focus();
}
} else {
G1 = window.open("
http://www.flexworkout.com/staff_1.htm", "G1",
"top=50,left=50,width=400,height=480,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0")
}
}
which is almost identical to
AM2 = "";
function pop_winAM2(psjs_url){
if(AM2){
if(AM2.closed){
AM2 = window.open("
http://www.flexworkout.com/staff_2.htm",
"AM2",
"top=50,left=50,width=400,height=480,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0")
} else {
AM2.focus();
}
} else {
AM2 = window.open("
http://www.flexworkout.com/staff_2.htm", "AM2",
"top=50,left=50,width=400,height=480,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0")
}
}
The answer is yes, just call one function, and use the parameter already in
the fucntion
The one function would read
function pop_win(psjs_url){
if(AM2){
if(AM2.closed){
AM2 = window.open("
http://www.flexworkout.com/" + psjs_url +
".htm", "AM2",
"top=50,left=50,width=400,height=480,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0")
} else {
AM2.focus();
}
} else {
AM2 = window.open("
http://www.flexworkout.com/" + psjs_url +
".htm", "AM2",
"top=50,left=50,width=400,height=480,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0")
}
}
The call would be
href="pop_win('staff_1');"
The one thing I am not sure about is why each function references a global
varibale
G1, AM1 etc
and also why it has two paths - one for when the global exists and one for
when it doesn't
Perhaps it could be written
function pop_win(psjs_url){
var wind = window.open("
http://www.flexworkout.com/" + psjs_url +
".htm", " ",
"top=50,left=50,width=400,height=480,resizable=0,toolbar=0,scrollbars=0,location=0,status=0,menubar=0")
wind.focus()
}
Try it and see