Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Firefox IFRAME will not print after first attempt

Reply
Thread Tools

Firefox IFRAME will not print after first attempt

 
 
zlarson@gmail.com
Guest
Posts: n/a
 
      08-08-2006
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.

 
Reply With Quote
 
 
 
 
zlarson@gmail.com
Guest
Posts: n/a
 
      08-08-2006
ummmm...thanks?

Randy Webb wrote:
> http://www.velocityreviews.com/forums/(E-Mail Removed) 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/


 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      08-08-2006
(E-Mail Removed) 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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Firefox 2 print and print preview only shows first page R.Ig Firefox 3 02-14-2007 01:10 AM
Can't locate object method "first" via package "attempt" (perhaps you forgot to load "attempt"?) at .... GMI Perl Misc 3 06-19-2005 10:44 PM
Firefox Browser Won't Open After Failed Updating Attempt: Need Help With Error Msg., Please Robert11 Computer Support 6 04-24-2005 01:20 PM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments