Firefox IFRAME will not print after first attempt

Discussion in 'Javascript' started by zlarson@gmail.com, Aug 8, 2006.

  1. Guest

    I have a website where a div's innerHTML is replaced with a string:
    <input type="button" name="myButton" id="myButton"
    onClick="printReport();"><IFRAME name="myFrame" id="myFrame"></IFRAME>
    which holds a report. when the button is clicked it calls a function
    to print the IFRAME:

    function printReport()
    {
    if(document.getElementById('myFrame')){
    if (navigator.appName.toUpperCase() == 'MICROSOFT
    INTERNET
    EXPLORER'){
    document.myFrame.focus();
    document.myFrame.print();
    }else{
    window.frames['myFrame'].print();
    }
    }



    }


    when the user gets to this report they can print it the first time, but

    if they get another item and try to come back and print its report the
    print button fails. i have put in alerts before and after the
    window.frames['myFrame'].print(); and it hits both of them. keep in
    mind this page is all using xmlHttpRequest and I have one big "load
    div" where its innerHtml is constantly being replaced with remote html
    strings. i first thought maybe i was ending up with multiple objects
    with the same ID name both i watched the DOM with the Firefox tool and
    that is not the case. The is only failing in Firefox. all is well in
    IE. Thanks.
    , Aug 8, 2006
    #1
    1. Advertising

  2. Guest

    ummmm...thanks?

    Randy Webb wrote:
    > said the following on 8/8/2006 2:32 PM:
    > > I have a website where a div's innerHTML is replaced with a string:
    > > <input type="button" name="myButton" id="myButton"
    > > onClick="printReport();"><IFRAME name="myFrame" id="myFrame"></IFRAME>
    > > which holds a report. when the button is clicked it calls a function
    > > to print the IFRAME:
    > >
    > > function printReport()
    > > {
    > > if(document.getElementById('myFrame')){

    >
    > So, you test for getElementById and then proceed to assume it supports
    > window.frames as well?
    >
    > > if (navigator.appName.toUpperCase() == 'MICROSOFT
    > > INTERNET
    > > EXPLORER'){

    >
    > Your script just went in the trash as it's utter junk after the use of
    > navigator and any of it's properties. And, for the record, the above
    > test does *not* identify IE.
    >
    > > document.myFrame.focus();
    > > document.myFrame.print();
    > > }else{
    > > window.frames['myFrame'].print();
    > > }
    > > }
    > >
    > >
    > >
    > > }

    >
    > function printReport(){
    > window.frames['myFrame'].focus();
    > window.frames['myFrame'].print();
    > alert('Look Ma, only three lines and no navigator crap check!!!')
    > }
    >
    > --
    > Randy
    > comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    > Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    , Aug 8, 2006
    #2
    1. Advertising

  3. Randy Webb Guest

    said the following on 8/8/2006 2:32 PM:
    > I have a website where a div's innerHTML is replaced with a string:
    > <input type="button" name="myButton" id="myButton"
    > onClick="printReport();"><IFRAME name="myFrame" id="myFrame"></IFRAME>
    > which holds a report. when the button is clicked it calls a function
    > to print the IFRAME:
    >
    > function printReport()
    > {
    > if(document.getElementById('myFrame')){


    So, you test for getElementById and then proceed to assume it supports
    window.frames as well?

    > if (navigator.appName.toUpperCase() == 'MICROSOFT
    > INTERNET
    > EXPLORER'){


    Your script just went in the trash as it's utter junk after the use of
    navigator and any of it's properties. And, for the record, the above
    test does *not* identify IE.

    > document.myFrame.focus();
    > document.myFrame.print();
    > }else{
    > window.frames['myFrame'].print();
    > }
    > }
    >
    >
    >
    > }


    function printReport(){
    window.frames['myFrame'].focus();
    window.frames['myFrame'].print();
    alert('Look Ma, only three lines and no navigator crap check!!!')
    }

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Aug 8, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer

    Login attempt not successful after deploy???

    VB Programmer, Feb 8, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    4,388
    palmerman
    Sep 6, 2006
  2. Daedalous
    Replies:
    3
    Views:
    660
    Daedalous
    Jan 16, 2004
  3. GMI
    Replies:
    3
    Views:
    479
    Tad McClellan
    Jun 19, 2005
  4. FatBo
    Replies:
    0
    Views:
    463
    FatBo
    Dec 20, 2005
  5. jon
    Replies:
    10
    Views:
    261
    Evertjan.
    Dec 6, 2006
Loading...

Share This Page