如何将当前页面内容附加到另一个页面? [英] How to append current page contents to another page?

查看:104
本文介绍了如何将当前页面内容附加到另一个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将页面一个是源页面,另一个是复制,我需要将一些div元素传递给其他页面主体。我做了一半,在这里我使用setTimeOut函数
如何做到无超时功能?
和浏览器应显示网址。

源页面:

 < html> 
< head>
< script src =http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js>< / script>
< / head>
< body>

< script>
函数copyCon(){

var p = document.getElementById(1);
var p_prime = p.cloneNode(true);
var w = window.open('printcopy.html');

setTimeout(function(){
w.document.body.appendChild(p_prime);
},1000);
}

< / script>

< button onclick =copyCon()>复制< / button>
< div id =1style =width:500px; height:500px; border:1px solid black; position:relative>

< h3>这是测试标题< / h3>
< p style =top:60px; left:20px; position:absolute;>测试段落< / p>

< input type =textstyle =position:absolute; top:40px; left:20px/>

< / div>

< / body>
< / html>

复制:

 < HTML> 
< head>
< / head>
< body>
< / body> < / HTML>

是否有任何访问元素和执行复制页面功能的方法?

解决方案

我自己找到解决方案

  function copyCon (){


var w = window.open('printcopy.html');
w.onload = function(){
var p = document.getElementById(1);
var p_prime = p.cloneNode(true);
w.document.body.appendChild(p_prime);
};
}

感谢支持

I have to pages one is source page another is copy, I need to pass some div elements to other page body. I did half way, here I used setTimeOut function How to do without timeout function? and browser should display url.

source page:

<html>
    <head>        
        <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js"></script>
    </head>
    <body>

        <script>
            function copyCon(){

            var p = document.getElementById("1");
            var p_prime = p.cloneNode(true);
            var w    = window.open('printcopy.html');

            setTimeout(function(){ 
                w.document.body.appendChild(p_prime);
            }, 1000);
            }

        </script>

        <button onclick="copyCon()">copy </button>
        <div id = "1" style="width: 500px; height: 500px; border: 1px solid black; position: relative">

            <h3> this is a test heading </h3>
            <p style="top: 60px; left: 20px; position: absolute;"> test Paragraph</p>

            <input type="text" style="position: absolute; top: 40px; left: 20px"/>

        </div>

    </body>
</html>

copy:

<html>
    <head>
    </head>
    <body>        
    </body> </html>

and is there any way to access the elements and execute function of copy page?

解决方案

I found solution myself

function copyCon(){


   var w    = window.open('printcopy.html');
   w.onload = function(){
     var p = document.getElementById("1");
     var p_prime = p.cloneNode(true);
     w.document.body.appendChild(p_prime);
   };
 }

thanks for supporting

这篇关于如何将当前页面内容附加到另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆