在具有可变输出的 VBscript 数组中创建超链接
create hyperlinks within VBscript array with variable output
努力解决这个问题:更新了下面的编辑。
<%
doMenu
dim products
dim manu
dim website
products = Array("E-reader set: Kindle Paperwhite, 9","Leather tote, 0","Earrings, ","Skin care duo: Moisturizer, ","Throw pillow, ","Vitamix 5200, 9","Tea set: Le Creuset kettle, oo","Spring nail polish collection, ","Framed birthstone print, ","Cotton robe, ","Jewelry box, ","Water bottle, ","Polka-dot scarf, ","Makeup set: Eye palette, ","Sequin pouch, ","Ceramic set: Jar, ","Honeycomb perfume, ","3-jar jam set, ","Recipe box, ","Hair dryer, 0","Epicurious 11-piece cookware set, 0","Cookbook collection: 100 Days of Real Food by Lisa Leake, ","Threshold dining set: Placemats, ","Sodastream genesis, ","Alexia necklace, ","Wild & wolf garden tool set, ","Rattan floor basket, ","Olivia burton watch, 5","Yoga set: Mat, ","Hair-care system: Restore shampoo, ","")
manu = Array("leather case, ","","","eye serum, ","","","three organic tea blends, ","","","","","","","lip palette, ; brush set, ","","mug, ; tray, ","","","","","","Twelve Recipes by Cal Peternell, ; Better on Toast by Jill A. Donenfeld, ","; napkins","","","","","","bag, ; towel, ","conditioner, ; mask treatment, ","")
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","")
%>
以上代码填充了单个动态单页网站中的内容部分。 问题是 网站只输出副本/文本URL。 我需要它 link,最好 link 用 target="_blank"
换新的 window。我试过以下;通过一个已回答的建议——虽然我认为这可能是更好的做法,但它似乎并不 运行 与其他数组,并且破坏了站点以仅解析为白页。我试过将它包含在我的其他数组结构中,包含在同一包含中并分开并破坏站点。我还将 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' },
用大锤敲螺母:
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 字典对象。
您没有在数组中创建超链接。您在迭代数组的代码中创建它们:
<%
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
%>
就这么简单。
<a href="http://<% response.write(website(day_part-1))%>" target="_blank" ><% response.write(website(day_part-1))%></a>
仅将此内联包含在 仅 变量输出中是最优化和最实用的。单独使用此代码,内联;不改变数组。
努力解决这个问题:更新了下面的编辑。
<%
doMenu
dim products
dim manu
dim website
products = Array("E-reader set: Kindle Paperwhite, 9","Leather tote, 0","Earrings, ","Skin care duo: Moisturizer, ","Throw pillow, ","Vitamix 5200, 9","Tea set: Le Creuset kettle, oo","Spring nail polish collection, ","Framed birthstone print, ","Cotton robe, ","Jewelry box, ","Water bottle, ","Polka-dot scarf, ","Makeup set: Eye palette, ","Sequin pouch, ","Ceramic set: Jar, ","Honeycomb perfume, ","3-jar jam set, ","Recipe box, ","Hair dryer, 0","Epicurious 11-piece cookware set, 0","Cookbook collection: 100 Days of Real Food by Lisa Leake, ","Threshold dining set: Placemats, ","Sodastream genesis, ","Alexia necklace, ","Wild & wolf garden tool set, ","Rattan floor basket, ","Olivia burton watch, 5","Yoga set: Mat, ","Hair-care system: Restore shampoo, ","")
manu = Array("leather case, ","","","eye serum, ","","","three organic tea blends, ","","","","","","","lip palette, ; brush set, ","","mug, ; tray, ","","","","","","Twelve Recipes by Cal Peternell, ; Better on Toast by Jill A. Donenfeld, ","; napkins","","","","","","bag, ; towel, ","conditioner, ; mask treatment, ","")
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","")
%>
以上代码填充了单个动态单页网站中的内容部分。 问题是 网站只输出副本/文本URL。 我需要它 link,最好 link 用 target="_blank"
换新的 window。我试过以下;通过一个已回答的建议——虽然我认为这可能是更好的做法,但它似乎并不 运行 与其他数组,并且破坏了站点以仅解析为白页。我试过将它包含在我的其他数组结构中,包含在同一包含中并分开并破坏站点。我还将 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' },
用大锤敲螺母:
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 字典对象。
您没有在数组中创建超链接。您在迭代数组的代码中创建它们:
<%
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
%>
就这么简单。
<a href="http://<% response.write(website(day_part-1))%>" target="_blank" ><% response.write(website(day_part-1))%></a>
仅将此内联包含在 仅 变量输出中是最优化和最实用的。单独使用此代码,内联;不改变数组。