Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simple javascript not working in Safari

Posted on 2008-06-20
2
Medium Priority
?
1,552 Views
Last Modified: 2013-12-07
Dear all,

The following javascript works great in all browsers but Safari.
It opens a centered pop up when the link is clicked, but in Safari I get a full window.
How can it be fixed for it to work in Safari??

Thanks very much in advance!!
<html>
<head>
 
<script language="javascript">
 
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
</script>
</head>
 
<body>
 
<a href="mypage.htm" onclick="NewWindow(this.href,'name','431','341','no');return false" >Open pop up</a>
 
</body>
</html>

Open in new window

0
Comment
Question by:Dada44
2 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 21833094
save this as hielo.html and try it:
<html>
<head>
 
<script language="javascript">
 
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
 
	LeftPosition = parseInt( (screen.width) ? (screen.width-w)/2 : 0);
	TopPosition = parseInt( (screen.height) ? (screen.height-h)/2 : 0);
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=yes';
	win = window.open(mypage,myname,settings)	
}
</script>
</head>
 
<body>
 
<a href="http://www.google.com" onclick="NewWindow(this.href,'theWindow','431','341','no');return false" >Open pop up</a>
 
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:Dada44
ID: 31469133
Thanks!!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question