开发者

ASP image rotator

So I'm pretty new to ASP, and want to use a script like this: http://www.w3schools.com/ASP/showasp.asp?filename=demo_adrotator

To randomly load an image when the page is loaded, but I don't want to link it. Any thoughts on how I can m开发者_如何学运维odify the example to be a simple rotator?


If all your images are named the same with a number difference, here's a quick way to do it:

<img src="images/img<%= Int(Rnd * 6)+1 %>.jpg" />

In this scenario, your pictures are all in the images folder are are called img#.jpg where # ranges from 1 to 6.

But to be honest, you don't really need ASP to do this. You could just use javascript to get the random url.


You can use the method mentioned in the comments

< img src="images/img<%= Int(Rnd * 2)+1 %>.jpg" / >

but you must first declare the Randomize statement or it will always return the same number

< % Randomize %>

< img src="images/img<%= Int(Rnd * 2)+1 %>.jpg" / >

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜