please give me a solution to this.
when a button is clicked I want to print a page specified in form action attribute using javascirpt:print() but without redirecting to that page
please give me a solution to this. when a button is clicked I want
Share
You can’t print a page the browser isn’t showing. You can only ask the browser to show the print dialog, which will offer to print the page the browser is currently showing.
You could open a new window, though, and do it that way:
If you control the other page, ideally you’d trigger the
printcall from within the other page when the page is fully loaded. On most browsers, the above works fine, but if I recall correctly on some browsers if theprintcall happens before the page is fully loaded, you don’t quite get what you want…Note that the code above will only work in direct response to a user action, such as a click on a button. Otherwise, the browser’s pop-up blocker will prevent it happening.