Jag*_*esh 5 html javascript jquery jquery-ui jquery-plugins
我想从 div 中的外部 url 加载页面,而不需要 IFrame 或对象,我需要替代方法。谁能帮我吗。
\n\n它仅在我使用 Iframe 或对象时才有效。
\n\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html>\n <head>\n <title>Test page</title>\n <script src="https://code.jquery.com/jquery-1.7.2.min.js"></script>\n <script>\n $(document).ready(function() { \n $("#siteloader").load( "https://www.w3schools.com" );\n });\n </script>\n </head>\n <body>\n <div id="siteloader"></div>\xe2\x80\x8b \n </body>\n</html>\nRun Code Online (Sandbox Code Playgroud)\n
正如 @DefyGravity 在这篇关于嵌入页面的文章中的评论所提议的,该网站(在本例中w3schools.com需要允许您的网站访问内容)。
如果您有权访问要访问的外部站点,则可以将Origin: http://requestSite.com标头发送到http://w3schools.com,但w3schools.com必须发回Access-Control-Allow-Origin: http://requestSite.com标头,但这是我知道它可能的唯一方法(并且只有当您有访问您要加载的其他站点的服务器)。
查看这个 jsfiddle 的控制台输出,它支持我上面的理论:http://jsfiddle.net/ctnopep3/