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/