Solved

Simple javascript not working in Safari

Posted on 2008-06-20
2
1,493 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now