View Full Version : How do i get ASP code to open in a new window
caffeine
07-23-03, 01:36 AM
Hey,
I'm using Banner Manager 0.8 on my website and i would like the ads to open in a new window. I'm really new to the whole idea of ASP so i'm pretty stumped on how to do it myself
WHen i go to generate code it gives me:
<%=BM_GetRndBanner(2, 2)%>
but when the resulting link is clicked, it opens in the same frame,
can someone give me some idea on how to fix this,
thank you for reading this,
JB
Stealth
07-23-03, 03:00 AM
find the BM_GetRndBanner() function and there will likely to be a link somewhere in the coding. change the target url to open in a _blank window. e.g
<a href="www.website.com" target="_blank">Click Here</a>
im not familiar with the Banner Manager script so if it doesnt work post the code to the whole function
caffeine
07-23-03, 08:47 PM
I found the function and got all this. i tried to edit it to put the target in, bt it showed me an ASP error saying invaild character
please have a look at this
function BM_GetRndBanner(zoneId, typeId)
dim pesoTot, rndBanner, nBanner, counter
call BM_OpenDb()
BM_mySql="SELECT * FROM banner WHERE zoneId="&zoneId&" AND typeId="&typeId
set BM_rs = Server.CreateObject("ADODB.RecordSet")
BM_rs.open BM_mySql, BM_conn
if BM_rs.EOF then
call BM_CloseDb()
BM_GetRndBanner = " "
Exit function
end if
nBanner = BM_rs.recordCount
pesoTot = 0
' Max range of selection
do while not BM_rs.EOF
pesoTot = pesoTot + BM_rs("peso")
BM_rs.Movenext
loop
' Pick a random value in range
Randomize
rndBanner = int(rnd * pesoTot)
' Pick the relative banner
BM_rs.Movefirst
counter = 0
do while counter + BM_rs("peso") < rndBanner
counter = counter + BM_rs("peso")
BM_rs.MoveNext
loop
if BM_rs("isHTML")=-1 then
Randomize
BM_GetRndBanner = "<!--BannerManager Start-->"&vbcrlf&replace(BM_rs("codiceHTML"),"[rnd]",int(rnd*100))&vbcrlf&"<!--BannerManager End-->"
else
BM_GetRndBanner = "<!--BannerManager Start-->"&vbcrlf&"<a href="""&BMPath&"redir.asp?id="& BM_rs("bannerId")&"""><img border=""0"" width="""&BM_rs("larghezza")&""" heigth="""&BM_rs("altezza")&""" alt="""&BM_rs("altText")&""" src="""&BM_rs("ImageURL")&"""></a>"&vbcrlf&"<!--BannerManager End-->"
end if
BM_mySql="UPDATE banner SET impression="&(BM_rs("impression")+1)&" WHERE BannerId="&BM_rs("bannerId")
BM_rs.close
set BM_rs = BM_conn.execute(BM_mySql)
set BM_rs = nothing
call BM_CloseDb()
end function
Still not sure what goes where,
thanks,
JB
Stealth
07-24-03, 04:16 AM
ok ... here goes
function BM_GetRndBanner(zoneId, typeId)
dim pesoTot, rndBanner, nBanner, counter
call BM_OpenDb()
BM_mySql="SELECT * FROM banner WHERE zoneId="&zoneId&" AND typeId="&typeId
set BM_rs = Server.CreateObject("ADODB.RecordSet")
BM_rs.open BM_mySql, BM_conn
if BM_rs.EOF then
call BM_CloseDb()
BM_GetRndBanner = " "
Exit function
end if
nBanner = BM_rs.recordCount
pesoTot = 0
' Max range of selection
do while not BM_rs.EOF
pesoTot = pesoTot + BM_rs("peso")
BM_rs.Movenext
loop
' Pick a random value in range
Randomize
rndBanner = int(rnd * pesoTot)
' Pick the relative banner
BM_rs.Movefirst
counter = 0
do while counter + BM_rs("peso") < rndBanner
counter = counter + BM_rs("peso")
BM_rs.MoveNext
loop
if BM_rs("isHTML")=-1 then
Randomize
BM_GetRndBanner = "<!--BannerManager Start-->"&vbcrlf&replace(BM_rs("codiceHTML"),"[rnd]",int(rnd*100))&vbcrlf&"<!--BannerManager End-->"
else
BM_GetRndBanner = "<!--BannerManager Start-->"&vbcrlf&"<a href="""&BMPath&"redir.asp?id="& BM_rs("bannerId")&" target=""_blank""""><img border=""0"" width="""&BM_rs("larghezza")&""" heigth="""&BM_rs("altezza")&""" alt="""&BM_rs("altText")&""" src="""&BM_rs("ImageURL")&"""></a>"&vbcrlf&"<!--BannerManager End-->"
end if
BM_mySql="UPDATE banner SET impression="&(BM_rs("impression")+1)&" WHERE BannerId="&BM_rs("bannerId")
BM_rs.close
set BM_rs = BM_conn.execute(BM_mySql)
set BM_rs = nothing
call BM_CloseDb()
end function
hth
Stealth
Does your Banner Manager work like this, everytime a page loads it loads a new banner from the list you made? You can try this banner rotator i use on my site, its really good, and simple!
Name this file "global.asa"
====================
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
End Sub
Sub Application_OnEnd
End Sub
Sub Session_OnStart
session("ad")=0
End Sub
Sub Session_OnEnd
End Sub
</SCRIPT>
Name this file "468x60.asp" (u can name this file whatever you want)
====================
<%
if session("ad")=10 then
session("ad")=1
else
session("ad")=session("ad")+1
end if
%>
<% Select Case session("ad") %>
<% case 1 %>
< a href="http://www.google.ca">Google</a>
<% case 2 %>
< a href="http://www.google.ca">Google</a>
<% case 3 %>
< a href="http://www.google.ca">Google</a>
<% case 4 %>
< a href="http://www.google.ca">Google</a>
<% case 5 %>
< a href="http://www.google.ca">Google</a>
<% End select %>
You can add as many cases as you need (ex. <% case 1 %> up to <% case 40 %>) if you add more make sure you change the, 2nd line of this code "if session("ad")=5 then" , change the 5 to whatever number of cases you have. You can use this code for any banner size too, like 160x800 and so on. Make sure the global.asa file is in the same folder these files. You can use any kind of HTML link you want, like text links, banner links, custom links like banners with textfield search boxes. ANY HTML.
To add this in a .asp page, use <!--#include virtual="adrotator/468x60.asp" -->
OMG im sorry, my mistake, look at the 2nd line of 468x60.asp, you will see "if session("ad")=10 then" change the 10 to 5. You can also leave the 10 and add more cases.
Ex:
<%
if session("ad")=10 then
session("ad")=1
else
session("ad")=session("ad")+1
end if
%>
<% Select Case session("ad") %>
<% case 1 %>
< a href="http://www.google.ca">Google</a>
<% case 2 %>
< a href="http://www.google.ca">Google</a>
<% case 3 %>
< a href="http://www.google.ca">Google</a>
<% case 4 %>
< a href="http://www.google.ca">Google</a>
<% case 5 %>
< a href="http://www.google.ca">Google</a>
<% case 6 %>
< a href="http://www.google.ca">Google</a>
<% case 7 %>
< a href="http://www.google.ca">Google</a>
<% case 8 %>
< a href="http://www.google.ca">Google</a>
<% case 9 %>
< a href="http://www.google.ca">Google</a>
<% case 10 %>
< a href="http://www.google.ca">Google</a>
<% End select %>
You see??, as long as you have 10 cases and 10 at the top, it will all work out, and if you change the 10 at the top to lets say 7, you would have to delete case 10,9,8.
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.