ส่วนประกอบASP AdRotator
ส่วนประกอบ ASP AdRotator
คอมโพเนนต์ ASP AdRotator สร้างออบเจ็กต์ AdRotator ที่แสดงรูปภาพที่แตกต่างกันทุกครั้งที่ผู้ใช้เข้าสู่หรือรีเฟรชหน้า ไฟล์ข้อความมีข้อมูลเกี่ยวกับรูปภาพ
หมายเหตุ: AdRotator ไม่ทำงานกับเซิร์ฟเวอร์ข้อมูลทางอินเทอร์เน็ต 7 (IIS7)
ไวยากรณ์
<%
set adrotator=server.createobject("MSWC.AdRotator")
adrotator.GetAdvertisement("textfile.txt")
%>
ตัวอย่าง ASP AdRotator
สมมติว่าเรามีไฟล์ข้อความต่อไปนี้ ชื่อ "ads.txt":
REDIRECT banners.asp
*
w3s.gif
https://www.w3schools.com
Free Tutorials from W3Schools
50
xmlspy.gif
https://www.altova.com
XML Editor from Altova
50
บรรทัดด้านล่างเครื่องหมายดอกจันในไฟล์ข้อความด้านบนระบุชื่อรูปภาพ (โฆษณา) ที่จะแสดง ที่อยู่ไฮเปอร์ลิงก์ ข้อความสำรอง (สำหรับรูปภาพ) และอัตราการแสดงผล (เป็นเปอร์เซ็นต์)
บรรทัดแรกในไฟล์ข้อความด้านบนระบุว่าจะเกิดอะไรขึ้นเมื่อผู้เยี่ยมชมคลิกที่ภาพใดภาพหนึ่ง หน้าเปลี่ยนเส้นทาง (banners.asp) จะได้รับข้อความค้นหาพร้อม URL ที่จะเปลี่ยนเส้นทางไป
เคล็ดลับ:ในการระบุความสูง ความกว้าง และเส้นขอบของรูปภาพ คุณสามารถแทรกบรรทัดต่อไปนี้ภายใต้ REDIRECT:
REDIRECT banners.asp
WIDTH 468
HEIGHT 60
BORDER 0
*
w3s.gif
...
ไฟล์ "banners.asp" มีลักษณะดังนี้:
ตัวอย่าง
<%
url=Request.QueryString("url")
If url<>"" then Response.Redirect(url)
%>
<!DOCTYPE html>
<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("textfile.txt"))
%>
</body>
</html>
แค่นั้น!!
คุณสมบัติ ASP AdRotator
Property | Description | Example |
---|---|---|
Border | Specifies the size of the borders around the advertisement | <% set adrot=Server.CreateObject("MSWC.AdRotator") adrot.Border="2" Response.Write(adrot.GetAdvertisement("ads.txt")) %> |
Clickable | Specifies whether the advertisement is a hyperlink | <% set adrot=Server.CreateObject("MSWC.AdRotator") adrot.Clickable=false Response.Write(adrot.GetAdvertisement("ads.txt")) %> |
TargetFrame | Name of the frame to display the advertisement | <% set adrot=Server.CreateObject("MSWC.AdRotator") adrot.TargetFrame="target='_blank'" Response.Write(adrot.GetAdvertisement("ads.txt")) %> |
วิธีการ ASP AdRotator
Method | Description | Example |
---|---|---|
GetAdvertisement | Returns HTML that displays the advertisement in the page | <% set adrot=Server.CreateObject("MSWC.AdRotator") Response.Write(adrot.GetAdvertisement("ads.txt")) %> |