努力兑换此问题:更新了下面的修改。
<%
doMenu
dim products
dim manu
dim website
products = Array("E-reader set: Kindle Paperwhite, $119","Leather tote, $160","Earrings, $88","Skin care duo: Moisturizer, $62","Throw pillow, $90","Vitamix 5200, $449","Tea set: Le Creuset kettle, $1oo","Spring nail polish collection, $51","Framed birthstone print, $48","Cotton robe, $25","Jewelry box, $49","Water bottle, $35","Polka-dot scarf, $38","Makeup set: Eye palette, $44","Sequin pouch, $88","Ceramic set: Jar, $22","Honeycomb perfume, $54","3-jar jam set, $24","Recipe box, $34","Hair dryer, $200","Epicurious 11-piece cookware set, $320","Cookbook collection: 100 Days of Real Food by Lisa Leake, $20","Threshold dining set: Placemats, $10","Sodastream genesis, $90","Alexia necklace, $49","Wild & wolf garden tool set, $33","Rattan floor basket, $59","Olivia burton watch, $105","Yoga set: Mat, $40","Hair-care system: Restore shampoo, $28","")
manu = Array("leather case, $40","","","eye serum, $48","","","three organic tea blends, $50","","","","","","","lip palette, $40; brush set, $50","","mug, $18; tray, $15","","","","","","Twelve Recipes by Cal Peternell, $20; Better on Toast by Jill A. Donenfeld, $20","$10; napkins","","","","","","bag, $20; towel, $25","conditioner, $28; mask treatment, $4","")
website = Array("www.amazon.com","www.baggu.com","www.sarahhealydesign.com ","www.kiehls.com","www.Laylagrayce.com","www.vitamix.com","www.williams-sonoma.com","www.essie.com","www.minted.com","www.worldmarket.com","www.westelm.com","www.swellbottle.com","www.echodesign.com","www.maccosmetics.com","www.bodenusa.com","www.rosannainc.com","www.libraryofowers.com","www.murrayscheese.com","www.rifepaperco.com","www.shopt3micro.com","www.jcpenney.com", "www.amazon.com", "www.target.com", "www.surlatable.com","www.stelladot.com","www.burkedecor.com","www.landofnod.com","www.modcloth.com","www.gaiam.com","www.livingproof.com","")
%>
以上代码在单个动态单页网站中填充内容部分。 问题是网站仅输出复制/文本网址。 我需要它进行链接,最好使用 target="_blank"
链接到新窗口。我试过以下;通过一个回答的建议 - 虽然我认为这可能是更好的做法,它似乎并没有与其他阵列一起运行,并打破了网站只解析为白页。我已经尝试将其包含在我的其他数组结构中,包含在内并分开并打破网站。我还将arrUrls
的名称切换为website
并声明了昏暗arrUrls
等等,所有内容都打破了页面,因此仍然需要解决方案。
dim arrUrls
arrUrls = Array("www.amazon.com","www.baggu.com")
For x=0 To UBound(arrUrls)
currentUrl = arrUrls(x)
Response.Write("<a href=""http://""" & currentUrl & """ target=""_blank"">" & currentUrl & "</a>")
Next
在过去,我已经完成了以下的jQuery数组,并且喜欢类似的解决方案,因为内联和清晰的内容将是完美的。
{ value: "NYC", url: 'http://www.nyc.com' },
{ value: "LA", url: 'http://www.la.com' },
{ value: "Philly", url: 'http://www.philly.com' },
答案 0 :(得分:4)
您不会在数组中创建超链接。您可以在迭代数组的代码中创建它们:
<%
Dim arrUrls, x, currentUrl
arrUrls = Array("www.amazon.com","www.baggu.com")
For x=0 To UBound(arrUrls)
currentUrl = arrUrls(x)
Response.Write("<a href=""http://" & currentUrl & """ target=""_blank"">" & currentUrl & "</a>")
If x < UBound(arrUrls) Then Response.Write(" | ")
Next
%>
这很简单。
答案 1 :(得分:-1)
用大锤敲打螺母:
Class LinkBuilder
'You could go with a dictionar or other name/value pair collection
'But we will keep this simple-ish
Public Href
Public Target
Public CssClass
Public Style
Public Rel
Public Id
Public SetLink (iHref, iTarget, iClass, iStyle, iRel, iID)
Href = iHref
Target = iTarget
CssClass = iClass
Style = iStyle
Rel = iRel
Id = iID
End Function
Public GetOpenATag()
Dim output;
output = "<a href='" & Href & "'"
if Target is not null and Target <> '' then
output = output & " target='" & Target & "'"
end if
if Id is not null and Id <> '' then
output = output & " id='" & Id & "'"
end if
'YOu get the Idea... do the same for the other properties
output = output & " >"
End Function
End Class
'Now build your array of links
Dim arrLinks()
arrLinks(0) = new LinkBuilder.SetLink("www.amazon.com", "_blank", "external", null, null, null)
arrLinks(1) = new LinkBuilder.SetLink("www.baggu.com", null, null, null, null, null)
'now to get a link
Dim aLink = arrLinks(0).GetOpenATag() & "Amazon</a>"
这是一个非常粗略的轮廓,完全未经测试。但它应该给你一些工作。还要研究Asp字典对象。