【发布时间】:2022-12-04 08:10:51
【问题描述】:
$(document).ready(function(){
var imgURLs = [
'https://www.google.com.ua/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png',
"https://s.yimg.com/rz/p/yahoo_frontpage_en-US_s_f_p_205x58_frontpage_2x.png"
];
var randomIndex = Math.floor(Math.random() * imgURLs.length);
var imgURL = imgURLs[randomIndex];
setTimeout(function(){
lightcase.start({
href: imgURL,
// more options like width, height, etc.
});
},1000); // 1000 to load it after 1 second from page load
});
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title></title>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/lightcase/2.5.0/css/lightcase.css'>
</head>
<body>
<!-- partial:index.partial.html -->
<!-- partial -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/lightcase/2.5.0/js/lightcase.js'></script><script src="./script.js"></script>
</body>
</html>
我将在示例中向我的网站添加一个弹出窗口,但我想向在 js 代码中打开的图像添加超链接。 比如google图片打开,当我点击图片的时候,我想去google.com网页。请帮忙。
I haven't tried yet
【问题讨论】:
-
请阅读Something on my web site doesn't work. Can I just paste a link to it?。当外部资源消失或固定时,依赖于外部资源才能理解的问题变得毫无用处。创建一个minimal reproducible example并放入问题本身反而。 Stackoverflow 确实支持inline live demos
标签: javascript html popup lightcase.js