我必须创建一个灯箱并在那里打开外部URL的内容。 我不允许更改现有代码。此时它是一个指向页面的简单链接,现在必须加载到灯箱中。
我必须自己编写所有代码,所以没有像colorbox这样的插件。 我知道如何打开/关闭灯箱。只是无法弄清楚如何加载外部网址的内容。
我希望你们能帮助我:)。
提前致谢
答案 0 :(得分:5)
我认为你应该使用jQuery的load()方法。借助该方法,您可以从其他网址获取内容并将其作为html放入灯箱中。
$('#idofDiv').load('test.html', function() {
alert('Load was performed.');
});
答案 1 :(得分:-1)
Lightbox 2 uses the jQuery framework. Load jQuery and the Lightbox javascript files in the proper order.
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/lightbox.js"></script>
Include the Lightbox CSS file.
<link href="css/lightbox.css" rel="stylesheet" />
Then use image from external url in this way
<a href="http://www.hyperlinkcode.com" rel="lightbox" ><img src="/images/sample-image.gif" border="0"></a>
The orignal url for this was
http://hyperlinkcode.com/images/sample-image.gif