0

在我的博客上,我有一个数组的 html 编码。我从网站 blogskins 下载了这个 blogskin,它带有编码“数组”。我对此有点熟悉,但我不知道html代码我想知道你们是否可以帮助我?我得到的编码是...

<script type="text/javascript">
<!-- hide
numquotes = 3;
var quotes = new Array(numquotes);
quotes[0]="<img src=http://i589.photobucket.com/albums/ss333/HeartsAloud/i9.jpg>";
quotes[1]="<img src=http://i589.photobucket.com/albums/ss333/HeartsAloud/i6.jpg>";
quotes[2]="<img src=http://i589.photobucket.com/albums/ss333/HeartsAloud/i10.jpg>";
quotes[3]="<img src=http://i589.photobucket.com/albums/ss333/HeartsAloud/i7.jpg>";
quotes[4]="<img src=http://i589.photobucket.com/albums/ss333/HeartsAloud/i3.jpg>";
var rand = Math.floor(Math.random()*numquotes);
document.write(quotes[rand]);
// -->
</script></center>

我想将这些图像更改为我自己的图像,并且我有几个想要替换它的链接,所以它会读取我的用户名而不是 HeartsAloud。

http://s1286.photobucket.com/user/Aquallurement/media/Blogger/tumblr_luufej9POE1r2jjy2o1_500_zpsecce3309.gif.html

^ 一个这样的例子,每当我放置那个链接而不是已经存在的那个链接时,它在我保存时它永远不会出现。

每当您发布条目时,它只会随机化图片。任何人都可以帮忙吗?我使用了错误的链接吗?

4

2 回答 2

0

have you tried the built-in string functions, like replace?

 var str="Visit Microsoft!";
 var n=str.replace("Microsoft","W3Schools");

from: http://www.w3schools.com/jsref/jsref_replace.asp

so in your case it would be something like:

 newLink = quotes[0].replace('old_userame', 'your_username')
于 2013-04-20T21:00:45.133 回答
0

您修改后的版本如下所示:

<script type="text/javascript">
<!-- hide
numquotes = 5;
var quotes = new Array(numquotes);
quotes[0]='<img src="YOUR LINK GOES HERE BETWEEN THE QUOTES">';
quotes[1]='<img src="YOUR LINK GOES HERE BETWEEN THE QUOTES">';
quotes[2]='<img src="YOUR LINK GOES HERE BETWEEN THE QUOTES">';
quotes[3]='<img src="YOUR LINK GOES HERE BETWEEN THE QUOTES">';
quotes[4]='<img src="YOUR LINK GOES HERE BETWEEN THE QUOTES">';
var rand = Math.floor(Math.random()*numquotes);
document.write(quotes[rand]);
// -->
</script>

所以你用你的链接替换你的链接在引号之间,以获得:

quotes[0]='<img src="http://i1286.photobucket.com/albums/a601/Aquallurement/Blogger/tumblr_luufej9POE1r2jjy2o1_500_zpsecce3309.gif">';

确保您直接链接到图片,而不是 photobucket 页面(右键单击图片并在谷歌浏览器中选择复制图片 URL)

这是您发布的链接: http: //s1286.photobucket.com/user/Aquallurement/media/Blogger/tumblr_luufej9POE1r2jjy2o1_500_zpsecce3309.gif.html

这是图片的链接,您应该使用:http: //i1286.photobucket.com/albums/a601/Aquallurement/Blogger/tumblr_luufej9POE1r2jjy2o1_500_zpsecce3309.gif

于 2013-04-20T21:39:38.377 回答