• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

window.print

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I trigger this program in netscape, I get an error which tells me that
this.printButton has no property or event is not defined. But it can work in IE.
What is the problem?
Thanks a lot.
------
function printing() {
this.printButton.style.visibility='hidden'
window.print() <--- error
this.printButton.style.visibility='visible'
document.menubar.visible=false;
document.toolbar.visible=false;
}
------
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actully "this" is what is probably causing the problem.
you need to pass "this" to the function
 
Sophia Choi
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I pass 'this' as a parameter but I still receive the error
stack overflow in script, missing formal parameter :function printing(this),
printing is not defined.
write onload printing(this) in the body
div id=printButton
Ready for printing.
end of div
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
using the onload with pasdsing this is not going to work when the button has nothing to do with that object
You are going to have to use the whole name for the button
document.FormName.ElementName.style="blah"
<body onload="printing()" gt;
<script>
function printing(){
document.FormName.ElementName.style="blah"
window.print();
document.FormName.ElementName.style="blah"
}
</script>
 
Sophia Choi
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My caller function is not inside the form.
"div id='printButton'
Inside , there is a button to call printing()

end of div
other messages....."
I have tried to access it like document.printButton.style....
I still have an error.
How can I get access to div ?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
document.FormName.ButtonName.style="hmmm:hmm"
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sophia,
Try something like this..for Netscape
document.layers['printButton'].style.visibility
you can first check for browser and then write code accordingly.
you can check for browsers like this
var isIE = document.all
var isN4 = document.layers
var isN6 = document.getElementById
if(isIE)
{
your code
}
else if(isN4)
{
document.layers['printButton'].style...whatever..
}
else if(isN6)
{
document.getElementById('printButton').style...
}
try this. I hope it should work
 
Sophia Choi
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both Eric and Hiren.
Hiren, your code can work in IE and N7.0. My users use Netscape 4.79 mostly. doucument.layers['printButton'].style seems not take effective for them.
 
Hiren Pathak
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sophia,
Try this for N4 versions..
document.printButton.visibility = "hide"
and
document.printButton.visibility = "show"
I am copying one code for showing and hiding of layers...take a look. this works for both N4 as well as IE

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic