如何使 html 页面显示来自另一个 url 的内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15821278/
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 make a html page to show content from another url
提问by user1948847
I want to make a html page that act kind like google cache.
我想制作一个类似于 google 缓存的 html 页面。
Say in my homepage HOME, I have a link A to a website B, and when I click on A, the page that comes out will display the content of another page, with a floating bar on top that has some functions of my own choices.
说在我的主页HOME,我有一个链接A到一个网站B,当我点击A时,出来的页面会显示另一个页面的内容,顶部有一个浮动栏,有一些我自己选择的功能.
For example, I want my link to show google.com, but I also want to add a button(floating bar, anything) to that google.com that allows me to return to my own webpage when pressed.
例如,我希望我的链接显示 google.com,但我还想向该 google.com 添加一个按钮(浮动栏,任何东西),以便在按下时返回我自己的网页。
Can someone provide me some useful resources for me too look at, or even better a solution template? :)
有人可以为我提供一些有用的资源,或者更好的解决方案模板吗?:)
Thanks!
谢谢!
采纳答案by Evan Shortiss
An iframe sounds like it may be what you need, but I'm not 100% sure after reading your description. The iframe will show content from another URL in your page. Once you have that all you need to do is style the page and use CSS/JavaScript to add in your functionality as described.
iframe 听起来可能正是您所需要的,但在阅读您的描述后,我并不能 100% 确定。iframe 将显示来自您页面中另一个 URL 的内容。一旦你有了这些,你需要做的就是设置页面的样式并使用 CSS/JavaScript 来添加你描述的功能。
Check out this: http://www.w3schools.com/tags/tag_iframe.asp
回答by Kevin Gurney
You could use an <iframe>
in order to display an external webpage within your webpage.
Just place the url of the webpage that you want to display inside the quotes of the src
attribute.
您可以使用 an<iframe>
来在您的网页中显示外部网页。只需将要显示的网页的 url 放在src
属性的引号内。
<iframe src="http://www.webpage.com" width="400" height="400"></iframe>
回答by domistiller
Either you use an iframe or you load the site via AJAX into a div (e.g. using jQuerys load()
method).
要么使用 iframe,要么通过 AJAX 将站点加载到 div 中(例如使用 jQuerysload()
方法)。
回答by Brian Phillips
Here's the general idea:
这是一般的想法:
HTML:
HTML:
<a href="#" id="link">Click Here</a>
<iframe id="frame" src="http://www.w3schools.com" scrolling="yes"></iframe>
Some jQuery (not tested):
一些 jQuery(未测试):
$(document).ready(function() {
$('#frame').hide();
$('#link').click(function () {
$('#frame').show();
})
})
Style it as necessary
根据需要设置样式
Note- this answer in no way endorses w3schools.com :-) . Please see w3fools.com/
注意- 这个答案绝不支持 w3schools.com :-) 。请参阅w3fools.com/