我怎么可以复制的弹出框的内容在JavaScript或jQuery的弹出、我怎么、内容、jQuery

2023-09-10 21:09:24 作者:人走心凉

我想在弹出框中打开一个URL(另一个域),然后要到该网页的内容的全部内容复制或者到剪贴板,或在一个变量。所以,我可以在我的web应用程序中使用它。

I want to open a URL (of another domain) in a popup box and then want to copy the whole content of that web page's contents either into the clipboard or in a variable. So that I can use it in my web application.

我的code是像

function openWin()
{
    myWindow=window.open("http://www.abcxyz.com","","width=400,height=200");

    //some code for copy content
    myWindow.close();
}

该功能显示,我要访问的网页。我需要的是复制的内容。

This function displays the webpage that i want to access. What I need is to copy that content.

请注意:

我不能使用AJAX的内容复制的URL(它产生的,因为同源策略的错误)。 在我无法使用跨域AJAX:唯一的身份验证后,网站URL答复和饼干都存储在我的浏览器,所以要求必须由浏览器发起,而不是从任何服务器。

推荐答案

也许你可以试试这个:

function openWin(){
   m = window.open("some.url.here");
   m.addEventListener("load", function(){func(m);});
}

function func(v){
   var c = v.document.body.innerHTML;
   v.close();
}