Javascript and frames; IE vs Mozilla

Discussion in 'JavaScript' started by hitesite, Jun 4, 2007.

  1. #1
    I have two frames: one i want to display and a hidden one I want to print when a print button is clicked in the displayed frame.

    Here's the frame code:

    <frameset rows="100%,*">
    <frame src="disclosure1.htm" name="frameA">
    <frame src="disclosure2.htm" Name="frameB">
    </frameset>

    and here's the button code in frameA:

    <input type="button" class="button" value="Print This Page" onclick="parent.frameB.focus();window.print()">

    This works fine in IE and prints frameB, but with Mozilla it just prints frameA. Could some knowledgeable person please tell me what I need to do to make make it work with Mozilla? It would be appreaciated.

    Regards,

    Page Hite
     
    hitesite, Jun 4, 2007 IP
  2. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Put the function to print the window in the head of that document.

    
    <html>
    <head>
    <script type="text/javascript">
    
            function printThis(){
    
                     self.print();
    
            }
    </script>
    </head>
    
    Code (markup):


    Then call that function from the other document.

    
    
    <input type="button" class="button" value="Print This Page" onclick="parent.frames['frameB'].printThis()">
    
    
    Code (markup):
     
    Mike H., Jun 4, 2007 IP
  3. hitesite

    hitesite Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the prompt reply. By "that document", did you mean disclosure2.htm, the document I want to print? I did this and in IE the print button now prints frameA instead of frameB. Did I do it correctly and should it work for both IEand Mozilla?

    Regards,

    Page Hite
     
    hitesite, Jun 4, 2007 IP
  4. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
                self.print() 
    
    Code (markup):
    speaks for itself, don't you think? Why wouldn't you just move it to the other document and test it?

    The code is cross-browser.
     
    Mike H., Jun 5, 2007 IP
  5. hitesite

    hitesite Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for your help. Understand the issue now. I'm using this in the first frame with no script in the second.

    onclick="parent.frames['frameB'].focus(); parent.frames['frameB'].print()"

    Appears to be cross-browser.

    Appreciate your assistance.

    Regards,

    Page Hite
     
    hitesite, Jun 5, 2007 IP