PDA

View Full Version : asp/javascript separate window question


gcapp
10-24-2002, 05:08 PM
I have this line of asp code:

if rsUpcoming.Fields("Start_Date") <= date () then
response.write("<font color='navy'>" & "<b>" & rsUpcoming.Fields("Start_Date") & ": " & "</b>" & "<a href=eventinfo.asp?eventID=" & rsUpcoming.Fields("ID") & ">" & rsUpcoming.Fields("Event_Name") & "</a></font><br>")
else
response.write("<font color='navy'>" & "<b>" & rsUpcoming.Fields("Start_Date") & ": " & "</b>" & "<a href=eventinfo.asp?eventID=" & rsUpcoming.Fields("ID") & ">" & rsUpcoming.Fields("Event_Name") & "</a></font><br>")
end if


How would i put in code, so that the link would produce a separate window - what is the code? I'm not sure in asp how to put it in.

Thanks

Roy Sinclair
10-24-2002, 06:52 PM
if rsUpcoming.Fields("Start_Date") <= date () then
response.write("<font color='navy'>" & "<b>" & rsUpcoming.Fields("Start_Date") & ": " & "</b>" & "<a href=""eventinfo.asp?eventID=" & rsUpcoming.Fields("ID") & """ target=""_blank"">" & rsUpcoming.Fields("Event_Name") & "</a></font><br>")
else
response.write("<font color='navy'>" & "<b>" & rsUpcoming.Fields("Start_Date") & ": " & "</b>" & "<a href=""eventinfo.asp?eventID=" & rsUpcoming.Fields("ID") & """ target=""_blank"">" & rsUpcoming.Fields("Event_Name") & "</a></font><br>")
end if

gcapp
10-24-2002, 09:13 PM
Roy,
Thank you, that's work great. One added question, how can I add code to size the window?? You know like I want the window to come up at 300 width and 200 height??

Thanks
Gary

whammy
10-24-2002, 11:44 PM
<%
if rsUpcoming.Fields("Start_Date") <= date () then
response.write("<font color=""navy""><b>" & rsUpcoming.Fields("Start_Date") & ": </b><a href=""javascript: void window.open('eventinfo.asp?eventID=" & rsUpcoming.Fields("ID") & "','MyWin','width=300,height=200'"">" & rsUpcoming.Fields("Event_Name") & "</a></font><br>")

else

'the same kinda thing... basically you just comment any double quotes in the code with another one.
%>

:D

glenngv
10-25-2002, 09:00 AM
i'd do it this way to degrade well with javascript-disabled browsers.

response.write("<font color=""navy""><b>" & rsUpcoming.Fields("Start_Date") & ": </b><a href=""eventinfo.asp?eventID=" & rsUpcoming.Fields("ID") & """ target=""_blank"" onclick=""window.open(this.href,this.target,'width=300,height=200');return false;"">" & rsUpcoming.Fields("Event_Name") & "</a>")

the output would be something like this:

<a href="eventinfo.asp?eventID=123" target="_blank" onclick="window.open(this.href,this.target,'width=300,height=200');return false;">Event_Name</a>