javascript随机调用超链接产生地址的方法
代码如下:
- <script>
- var sites = [
- 'http://www.zidiu.com',
- 'http://www.jinhei.com',
- 'http://www.baidu.com',
- 'http://www.youtube.com'
- ];
- function randomSite() {
- var i = parseInt(Math.random() * sites.length);
- location.href = sites[i];
- }
- </script>
- <a href="#" onclick="randomSite();">Random</a>
复制代码
|