/    Sign up×
Community /Pin to ProfileBookmark

window.print problem in Opera browser

Hi,

I am trying to open a print dialog box in Opera browser using javascript code as
<script language=javascript>
window.print(); //This is working in IE, Netscape, Firefox, but not working in Opera
</script>

where as if I am using the following code Opera browser understands and able to open print dialog box
<input type=”button” value=”Print this page” onClick=”javascript:window.print();” ID=”Button1″ NAME=”Button1″>

My requirement is to open print dialog box in Opera browser using script block.
Can anyone help me?
Please revert back if u did not understand my question.

Thanks and Regards
Murthy.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@felgallMay 03.2006 — The page must be loaded before it can be printed in Opera. You oughtn't to want to print a part of a page before the rest loads anyway. So use the following code to open the print dialog AFTER the page finishes loading.

window.onload = window.print;
Copy linkTweet thisAlerts:
@svmurthyauthorMay 04.2006 — The page must be loaded before it can be printed in Opera. You oughtn't to want to print a part of a page before the rest loads anyway. So use the following code to open the print dialog AFTER the page finishes loading.

window.onload = window.print;[/QUOTE]



Hi, Thankyou very much for the suggestion.

I tried this, but not working. Any other alternative is there?
Copy linkTweet thisAlerts:
@jalarieMay 04.2006 — window.onload = window.print;[/QUOTE]
Did you miss the parens?
window.onload = window.print();
Copy linkTweet thisAlerts:
@svmurthyauthorMay 05.2006 — Did you miss the parens?
window.onload = window.print();[/QUOTE]


Hi,

I have not missed the parenthesis..

I tried window.onload = window.print(); but not succeeded.
Copy linkTweet thisAlerts:
@felgallMay 05.2006 — I actually tested it before posting. The code that I posted does work in Opera 8. The parentheses should NOT be there as that would be trying to print the page and pass the reult of the print to the onload event handler instead of telling the event handler to print onload. If it doesn't work in earlier versions of Opera then there is no way to get it to work in those versions. If you can't get it to work on Opera 8 then you have your browser set to disallow it.
Copy linkTweet thisAlerts:
@chasnzJun 27.2010 — I had the same problem in Opera and the only way I got it to work was to set a timeout for the print function:

function init() {

var objBrowse = window.navigator;

if (objBrowse.appName == "Opera") {

setTimeout('window.print()', 1000);

} else {

window.print();

}

}

window.onload = init;
×

Success!

Help @svmurthy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...