简体   繁体   English

使用window.open在javascript中打开div内的任何页面

[英]open any page inside div using window.open in javascript

I have the code: 我有代码:

var flashlaunchserver="http://devonestopdigital.s3.amazonaws.com/";

now i am opening the new window like: 现在我打开新窗口,如:

window.open(flashlaunchserver, "_blank",'left=0,top=0,width=1010,height=700,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,directories=no', false);

It is opens in new window But i want to open this window.open inside div tags. 它在新窗口中打开,但我想在div标签中打开此window.open。

is there any way. 有没有办法。

Because of the limitations of JavaScript's XmlHttpRequest object concerning cross-domain requests, you would need to build a page scraper on your server side that is accessible through AJAX. 由于JavaScript的XmlHttpRequest对象在跨域请求方面的局限性,您需要在服务器端构建一个页面抓取器,该页面抓取器可通过AJAX访问。 Then you could create an AJAX request locally that would call your function. 然后,您可以在本地创建一个AJAX请求,该请求将调用您的函数。

Your function would need to scrape out the <html> -> <body> tags and the ending tags. 您的函数将需要删除<html> -> <body>标签和结束标签。 Then the raw html could be inserted into your div with innerHTML . 然后可以使用innerHTML将原始html插入到div中。 This would be a lot of work to accomplish something that would be much simpler with iframes. 要完成一些使用iframe会更简单的事情,这将是很多工作。

Edit: As a side note, scraping tags out is touchy because you need to make sure you don't scrape out any necessary scripts, or resource includes. 编辑:附带说明,刮出标签很容易,因为您需要确保刮出任何必要的脚本或资源。

您只能在iframe中加载外部内容:

<iframe src="http://devonestopdigital.s3.amazonaws.com/"></iframe>

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

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