Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Javascript Problem in Safari 5.1.1 Version.
Old 11-12-2011, 10:03 AM Javascript Problem in Safari 5.1.1 Version.
Junior Talker

Posts: 2
Trades: 0
Hi Friends,

I am having a problem with javascript in safari 5.1.1.
i am using javascript code to print a popup page . it is working fine in all browsers but it is not working properly in safari 5.1.1(below Safari 5.1.1 it is working). The problem is it is not showing the content of the popup in safari 5.1.1 where as it is showing in other browsers.
Please help me. below is the code.

<html >
<head>
<title></title>
<script type="text/javascript" language="javascript">
function Print() {

var printcontent = "";
printcontent="<body bgcolor=blue>Hello</body>";
var winprint = window.open('', '', 'left=0,top=0,width=950,height=600,toolbar=0,scrol lbars=1,status=0,resizable=1');
winprint.document.open();
winprint.document.write(printcontent);
winprint.document.close();
winprint.focus();
winprint.print();
winprint.close();

}
</script>
</head>
<body >
<input type="button" value="Print" onclick="javascript:Print();" />
</body>
</html>
syago01 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-12-2011, 11:26 AM Re: Javascript Problem in Safari 5.1.1 Version.
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Try it when writing a valid full page, not just the portion you're currently doing.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 11-12-2011, 12:03 PM Re: Javascript Problem in Safari 5.1.1 Version.
Junior Talker

Posts: 2
Trades: 0
Quote:
Originally Posted by PaulW View Post
Try it when writing a valid full page, not just the portion you're currently doing.
hi
i am getting same problem when that quote is present in the full page also.
syago01 is offline
Reply With Quote
View Public Profile
 
Old 11-28-2011, 05:00 PM Re: Javascript Problem in Safari 5.1.1 Version.
Junior Talker

Posts: 1
Trades: 0
I was having the same problem but figured out a fix. There seems to be a timing problem with Safari 5.1. The solution is to add a setTimeout function to call the winprint.print() and winprint.close() functions. Here is what I did that works perfectly. Make sure you declare the winprint variable outside the function so it is available globally to other functions.

<script type="text/javascript" language="javascript">
var winprint;

function Print() {
var printcontent = "";
printcontent="<body bgcolor=blue>Hello</body>";
var winprint = window.open('', '', 'left=0,top=0,width=950,height=600,toolbar=0,scrol lbars=1,status=0,resizable=1');
winprint.document.open();
winprint.document.write(printcontent);
var shortpause=setTimeout("printme()",500);
}
function (printme) {
winprint.print();
winprint.close();
}
</script>

The timeout is really only necessary for Safari but in the above example it will provide a short pause to all browsers. In my real world code I use jQuery to test for the browser and if it is Safari I call this function.
jmerrikin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Javascript Problem in Safari 5.1.1 Version.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20175 seconds with 12 queries