×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

How to print a frame by issuing command in another frame? Merci Beaucoup...

I have a JavaScript question. Thanks for telling me how-to.

Let me examplify my question. I have a .HTML page, which contains two frames.
Frame 1 contains some meaningful contents.
Frame 2 contains a hyperlink under "Print",
with onClick attribute related to a JavaScript function. My purpose is to print the contents of Frame 1. I don't have luck here---Each time I click my link, I print out Frame2.

Enclosed is the skeleton code for Frame 2.

<html>
<title>FRAME 2</title>
<SCRIPT LANGAUGE="JavaSCRIPT">
function printFrame1(){
parent.Frame1.print();
}
</SCRIPT>
</head>
<body>

<A href='#' onclick="printFrame1()" > Print</a>
</body>
</html>
Report

Replies, comments and Discussions:

  • 工作学习 / IT杂谈 / How to print a frame by issuing command in another frame? Merci Beaucoup...
    I have a JavaScript question. Thanks for telling me how-to.

    Let me examplify my question. I have a .HTML page, which contains two frames.
    Frame 1 contains some meaningful contents.
    Frame 2 contains a hyperlink under "Print",
    with onClick attribute related to a JavaScript function. My purpose is to print the contents of Frame 1. I don't have luck here---Each time I click my link, I print out Frame2.

    Enclosed is the skeleton code for Frame 2.

    <html>
    <title>FRAME 2</title>
    <SCRIPT LANGAUGE="JavaSCRIPT">
    function printFrame1(){
    parent.Frame1.print();
    }
    </SCRIPT>
    </head>
    <body>

    <A href='#' onclick="printFrame1()" > Print</a>
    </body>
    </html>
    • If the frames are sibling frames in the current frameset and there is no typewrite error, I have no idea.
      • Yes, those two frames are siblings... but the code does not work.
    • It's for you, jabbor...
      Your javascript codes do work perfectly in Navigator. I think there's a bug in IE's "print()" function. However, I found a way to round over it.
      ......
      function printFrame1(){
      parent.Frame1.window.focus(); //put this line before print(), it works well in both NS and IE.
      parent.Frame1.print();
      }
      ......
      good luck.
      • Thank you, Neo. One of my friends, who has 2 years of JavaScript experiences, told this is related a flaw in IE. Thanks again!
        • You are always welcome, Jabber. :-) Yes, I recognized it's a flaw of IE in few minutes after I built several HTML pages. But my goal was to round over the flaw. Fortunately, I made it for you. :-)