从父页面获取内容

时间:2013-07-24 08:02:58

标签: javascript parent-child

当您点击打印笔记时,我希望弹出另一个窗口,显示您拍摄的笔记。就我而言,它一直显示为空白。

如果我需要提供更多详细信息,请与我们联系:

页面(1)带有文本区域

<textarea id="sermon_notes" cols="5" rows="5"></textarea>
<a href="../notes/print/forgiveness/index.html" target="_blank" class="btn_small_cmg">     <span>Print Notes</span></a>

页面(2)用javascript试图提取您在第(1)页上写的信息,以便它可以显示在第(2)页

<html>
  <head>
    <title>Media | New Foundation Christian Ministries </title>

       <link rel="stylesheet" href="../css/popout.css" media="screen" type="text/css" />
       <link rel="stylesheet" href="../css/print.css" media="print" type="text/css" />

    </head>

    <body class="about">
      <div class="wrap">
  <div class="header">
    <a href="javaScript:window.print();" class="print"><span>Print</span></a>
    <h1><img src="../images/logo.png" alt="New Foundation Christian Ministries" />       </h1>
</div>
<div class="content">
        <div class="page_header">
        <h2>Notes</h2>
    </div>
    <h1></h1>
        <h1>some text</h1>
        <small>ate</small>

        <br/><br/><br/>


            <h3>My Notes:</h3>
            <p>

            <script type="text/javascript">
                // Get the notes from the parent page
                var message_notes = window.opener.document.getElementById('sermon_notes').value;
                // Replace out the new line character with a <br>
                message_notes = message_notes.replace(new RegExp( "\\n", "g" ),"<br />");
                document.write(message_notes);
            </script>
            </p> 

</div>
<div class="footer">

   </div>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

我知道了,上面的代码工作得很好,我的链接不包含http而是文件。除非你有http,否则它将无法工作,因此它无法在本地服务器上运行。

谢谢大家的帮助。

相关问题