从父页面获取内容

Get content from the parent page

本文关键字:获取      更新时间:2023-09-26

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

请让我知道我是否应该提供更多细节:

带有文本区域的页面(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>

我明白了,我上面的代码工作得很好,因为我的链接不包含http,而是包含文件。除非你有http,否则它不会工作,所以它不会在你的本地服务器上工作。

谢谢大家的帮助。