如何使用 jquery 将外部内容加载到 div(想想嵌入式灯箱)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/588509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to load external content to a div using jquery (think embedded lightbox)
提问by user44585
Using Thickbox is great it allows me to load external sites into the thickbox and they retain their functionality, appearance, etc. I know how to load simple content into a div with jquery but I am stuck on how to load external content to a div in a page (preferably via onload event) and have that div act like Thickbox and retain the functionality and appearance without the popup thickbox window.
使用thickbox 很棒,它允许我将外部站点加载到thickbox 中,并且它们保留其功能、外观等。我知道如何使用jquery 将简单内容加载到div 中,但我坚持如何将外部内容加载到div 中一个页面(最好通过 onload 事件),并使该 div 的行为类似于 Thickbox 并保留功能和外观,而没有弹出的thickbox 窗口。
All of the sites are in different child directories but have the same parent.
所有站点都在不同的子目录中,但具有相同的父目录。
I hope I explained it well enough.
我希望我解释得足够好。
I am using jquery 1.3.1.
我正在使用 jquery 1.3.1。
采纳答案by UnkwnTech
Personally I'd just go for an iFrame, which from your description I think would provide the same functionality.
就我个人而言,我只会选择 iFrame,根据您的描述,我认为它会提供相同的功能。
回答by Shahid
Using jQuery load function is great.
使用 jQuery 加载功能很棒。
A simple example of code is $('#result').load('simple/test.html');
where #result
is the div where you will load external file and simple/test.html is the html page path to load.
一个简单的代码示例$('#result').load('simple/test.html');
,其中#result
是div在那里你会加载外部文件和简单/ test.html的是HTML页面的路径负载。
For more info just go to http://api.jquery.com/load/and follow the instructions.
有关更多信息,请访问http://api.jquery.com/load/并按照说明进行操作。
回答by Scott Evernden
Thickbox is(usually) an iframe .. iframe is pretty much your only solution for this if the content is from foreign websites (sites you dont control) ..
ThickBox的是(通常)的iframe .. IFRAME是一个很值得你为这个唯一的解决方案,如果内容是从国外网站(你不点控制)..