aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes window.Print() not working. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "window.Print() not working." Watch "window.Print() not working." New topic
Author

window.Print() not working.

Ashwani Yadav
Ranch Hand

Joined: May 23, 2002
Posts: 33
I am using two frames, in my first frame my "Print" button is there and from that button I want to print the another frame's document(HTML CSS).
So for that I have written the following Function:
function printReport()
{
parent.Main.focus();//"Main is my second Frame's name which I want to Print.
window.print();
}
The above function works well in IE but in netscape 6, nothing happens , it also doesn't give me any error message.
If any one have any idea about my problem please respond.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Quoted from O'Reilly Javascript book (the rhino book)
Simulates a click on the browser's Print button. IE5 and Netscape4 only

Looks like you're out of luck
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Try this:

It is tested in Netscape 7 Priview Release 1, Netscape 4.79 and Internet Explore 6 sp1
/Rene


Regards, Rene Larsen
Dropbox Invite
Ashwani Yadav
Ranch Hand

Joined: May 23, 2002
Posts: 33
Hello,
Thanks for the quick response, but by using this function I am getting access denied arror.
As my Print button in upper frame and the document which I want to print is lower one(i.e. main--Frame name).
Ashwani Yadav
Ranch Hand

Joined: May 23, 2002
Posts: 33
Ya now print pop up is opened on call of this function but it prints only the upper frame where as i am giving name of lower frame to print.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

This is how I did it:
index.html

top.html

main.html

Is this the way you are doing it too or almost to way?
/Rene
Ashwani Yadav
Ranch Hand

Joined: May 23, 2002
Posts: 33
Hello,
As said by you that following code is working, although I have seen ur code also that is working fine.
Actually in My second frame i.e. Main, I am generating Report in HTML CSS and that i want to be printed.
In the following function it is not going beyond
parent.Main.focus().
Could you please suggest me something regarding this.
---------------------------------------
<script language="javascript">
function printReport()
{
alert("Before if condition");
if (window.print)
{
alert("After if condition");
parent.Main.focus();
alert("After focus----");
parent.Main.print();
alert("Over");
}
}
</script>
------------------------------------
Ashwani Yadav
Ranch Hand

Joined: May 23, 2002
Posts: 33
The above witten function gives error "Access denied" when the frame which I am printing conatins HTML CSS document.
Does any body knows abot this?
 
Don't get me started about those stupid light bulbs.
 
subject: window.Print() not working.