Solved

Simple javascript not working in Safari

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

757 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

21 Experts available now in Live!

Get 1:1 Help Now