0
僅供參考,我不是一個程序員,所以任何事情都必須清楚地說明。使用jquery和colorbox的隨機Href
我在sharepoint中使用這個.js腳本。它工作正常!
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>ColorBox demo</title>
<link rel="stylesheet" href="http://www.jacklmoore.com/colorbox/example1/colorbox.css" />
</head>
<body>
<h1>Hello, there!</h1>
<h2>This is some content</h2>
<p>The popup will open in five seconds</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://www.jacklmoore.com/colorbox/jquery.colorbox.js"></script>
<script>
function openColorBox(){
$.colorbox({iframe:true, width:"40%", height:"30%", href: "http://172.16.96.254/pf17.html"});
}
setTimeout(openColorBox, 5000);
setTimeout(parent.$.colorbox.close, 15000);
</script>
</body>
</html>
我已經創建了一個本地內部網站的許多網頁。 pf1.html - pf21.html
我想在彈出窗口運行時隨機化這些。
我看過這個功能..在這個論壇發帖。
(的Math.random()* 11)
我怎樣才能將其添加到上面的腳本和隨機的網頁。
這是完全隨機剪輯
$(document).ready(function() {
$("a.colorbox").click(function() {
$(this).attr("href","print"+Math.floor(Math.random()*11)+".html");
});
我知道* 11套的頁數..