Javascript-форум (https://javascript.ru/forum/)
-   Элементы интерфейса (https://javascript.ru/forum/dom-window/)
-   -   Открыть окно в центре экрана (https://javascript.ru/forum/dom-window/11761-otkryt-okno-v-centre-ehkrana.html)

LRCenter 12.09.2010 10:54

Открыть окно в центре экрана
 
Как можно открыть окно строго по центру экрана, не отталкиваясь от абсолютных координат?

<a href='#' onclick="window.open('window.html','newwin','top=100, left=100, menubar=0, toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, width=600, height=300')">Открыть</a>

exec 12.09.2010 11:07

<a href="javascript://" onclick="_open( '/forum', 300 , 300 );">
	Ссылка
</a>

<script type="text/javascript">
	function _open( url, width, height ) {
		window.open( url, '', 'width=' + width + ',height=' + height + ',left=' + ((window.innerWidth - width)/2) + ',top=' + ((window.innerHeight - height)/2) );
	}
</script>

LRCenter 12.09.2010 11:12

exec, Спасибо! Почему я не могу поднять вам карму? До вас я поднимал кому-то еще.


Часовой пояс GMT +3, время: 21:27.