您好我正在尝试新的jquery插件:https://github.com/rewish/jquery-bgswitcher 我的问题是,当我尝试链接图像时,我得到的图像找不到404。
$("body").bgswitcher({
images:
[
"/Content/Images/landscape_argentina_mountain_lake_patagonia_clouds_nature.jpg",
"/Content/Images/2510_venezuela.jpg",
"/Content/Images/8.jpg",
"/Content/Images/IguazuFallsNationalParkathebordersofArgentinaandBrazil20130211.jpg",
"/Content/Images/Rio-Movie-Wallpaper-6.jpg",
"/Content/Images/snowy_mountains_patagonia_peaks_chile_farm_ultra_3840x2160_hd-wallpaper-1906502.jpg",
"/Content/Images/Sunset_And_Lightning_Over_River_FullHDWpp.com_.jpg"
],
loop: true,
interval: 5000,
effect: "face"
});
如何从我的地图/内容/图像链接来自visual studio的图像
答案 0 :(得分:1)
您可以添加此方法:
function getFull(a)
{//get full url including scheme , port and base dns
return location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: '') + a;
}
然后:
$("body").bgswitcher({
images:
[
getFull("/Content/Images/landscape_argentina_mountain_lake_patagonia_clouds_nature.jpg"),
getFull("/Content/Images/2510_venezuela.jpg"),
getFull("/Content/Images/8.jpg"),
getFull("/Content/Images/IguazuFallsNationalParkathebordersofArgentinaandBrazil20130211.jpg"),
getFull("/Content/Images/Rio-Movie-Wallpaper-6.jpg"),
getFull("/Content/Images/snowy_mountains_patagonia_peaks_chile_farm_ultra_3840x2160_hd-wallpaper-1906502.jpg"),
getFull("/Content/Images/Sunset_And_Lightning_Over_River_FullHDWpp.com_.jpg")
],
loop: true,
interval: 5000,
effect: "face"
});
所以(例如):
getFull("/Content/Images/landscape_argentina_mountain_lake_patagonia_clouds_nature.jpg")
将屈服:
https://lostechies.com/Content/Images/landscape_argentina_mountain_lake_patagonia_clouds_nature.jpg"
(^我在随机网站的控制台上运行示例,因此忽略基本网址。在您的网站中 - 它会没问题。)
效果编辑:
不是每次都计算整个网址,而是记住它:
function getFull(a)
{
return getFull.mem || (getFull.mem = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: '') + a,getFull.mem)
}