简体   繁体   English

如何在div标签中加载URL的内容?

[英]How to load the contents of a URL in a div tag?

I want to open a another page in <div></div> but when I do that it opens a new page. 我想在<div></div>打开另一个页面,但是当我这样做时,它会打开一个新页面。

I used iframe but that is discouraged, and it has scroll bars. 我使用iframe但不建议使用,它具有滚动条。

<div id="iframeLogin"><a href="first.php" target="_self">Link</a></div>

Is there anyway to open a page to this div? 反正有没有打开该div的页面?

I want it to autoload the page on to the DIV when I access the site. 我希望它在访问网站时将页面自动加载到DIV上。

You can use jQuery's load method. 您可以使用jQuery的load方法。

$(function() {
    $("#iframeLogin").load("first.php");
});

Note that if first.php is a complete HTML page, you'll want to only load a portion of the page. 请注意,如果first.php是完整的HTML页面,则只希望加载页面的一部分。

$("#iframeLogin").load("first.php #content");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM