Показано с 1 по 4 из 4

Тема: window.open help

  1. #1

    Регистрация
    19.07.2006
    Сообщений
    44
    Люди, как сделать, чобы попап открывался в середине экрана?

  2. #2

    Регистрация
    05.09.2005
    Сообщений
    160
    *.js файл
    Код:
    // (c)1999 by [Только зарегистрированные пользователи могут видеть ссылки. ]
    //
    // OpenWin withposition function
    //
    function win(link,title,width,height,xstyle,xpos,ystyle,ypos) {
    ****// link - url of target page
    ****// title - new window title (may be omitted)
    ****// width -;-)
    ****// height -;-)
    ****// xstyle - left,right,center
    ****// xpos - in pixels from left(+), center(+/-), right(+)
    ****// ystyle - top,bottom,center
    ****// ypos - same as xpos****
    ****//
    ****// Example in html
    ****// <script language=Javascript src=openwin.js>
    ****// </script>
    ****// <a href=javascript:win(&#39;test.html&#39;,&#39;&#39;,440,250,&#39;right&#39;,30,&#39;bottom&#39;,90)>Test</a>
    ****//
    ****var startx,starty
    ****startx=0
    ****starty=0
     * * * *if(xstyle==&#39;left&#39;) {
     *startx = xpos
     *}
    ****if(xstyle==&#39;center&#39;) {
     *startx = screen.width/2 - width/2 + xpos
     *}
    ****if(xstyle==&#39;right&#39;) {
     *startx = screen.width - width - xpos
     *}
     * * * * if(ystyle==&#39;top&#39;) {
     *starty = ypos
     *}
    ****if(ystyle==&#39;center&#39;) {
     *starty = screen.height/2 - height/2 + ypos
     *}
    ****if(ystyle==&#39;bottom&#39;) {
     *starty = screen.height - height - ypos
     *}
    ****winStats=&#39;scale=no,toolbar=no,location=no,directories=no,menubar=no,&#39;
    ****winStats+=&#39;scrollbars=no,width=&#39;+width+&#39;,height=&#39;+height
    ****winStats+=&#39;,left=&#39;+startx+&#39;,top=&#39;+starty+&#39;,screenX=&#39;+startx+&#39;,screenY=&#39;+starty
    ****floater=window.open(link,title,winStats)
    ****floater.focus()
    }
    function win2(link,title,width,height,xstyle,xpos,ystyle,ypos) {
    ****// link - url of target page
    ****// title - new window title (may be omitted)
    ****// width -;-)
    ****// height -;-)
    ****// xstyle - left,right,center
    ****// xpos - in pixels from left(+), center(+/-), right(+)
    ****// ystyle - top,bottom,center
    ****// ypos - same as xpos****
    ****//
    ****// Example in html
    ****// <script language=Javascript src=openwin.js>
    ****// </script>
    ****// <a href=javascript:win(&#39;test.html&#39;,&#39;&#39;,440,250,&#39;right&#39;,30,&#39;bottom&#39;,90)>Test</a>
    ****//
    ****var startx,starty
    ****startx=0
    ****starty=0
     * * * *if(xstyle==&#39;left&#39;) {
     *startx = xpos
     *}
    ****if(xstyle==&#39;center&#39;) {
     *startx = screen.width/2 - width/2 + xpos
     *}
    ****if(xstyle==&#39;right&#39;) {
     *startx = screen.width - width - xpos
     *}
     * * * * if(ystyle==&#39;top&#39;) {
     *starty = ypos
     *}
    ****if(ystyle==&#39;center&#39;) {
     *starty = screen.height/2 - height/2 + ypos
     *}
    ****if(ystyle==&#39;bottom&#39;) {
     *starty = screen.height - height - ypos
     *}
    ****winStats=&#39;scale=no,toolbar=no,location=no,directories=no,menubar=no,&#39;
    ****winStats+=&#39;scrollbars=yes,width=&#39;+width+&#39;,height=&#39;+height
    ****winStats+=&#39;,left=&#39;+startx+&#39;,top=&#39;+starty+&#39;,screenX=&#39;+startx+&#39;,screenY=&#39;+starty
    ****floater=window.open(link,title,winStats)
    ****floater.focus()
    }
    
    function closeWin()
    {
    ****window.close();
    }
    Правда может чуть перемудренно, но выход

  3. #3

    Регистрация
    23.03.2004
    Адрес
    Беларусь/Минск
    Сообщений
    926
    не понял, а зачем это??? стоит ли игра свеч (такого раздутого кода)?

  4. #4

    Регистрация
    07.07.2006
    Сообщений
    105
    Например вот так:
    Код:
    <script type="text/javascript">
    ****function openWindow(url, width, height){
     *var args = "height="+ height +",innerHeight="+ height;
     *args += ",width="+ width +",innerWidth="+ width;
     *if (window.screen){
     *****var x = (screen.availWidth - width) / 2;
     *****var y = (screen.availHeight - height) / 2;
     *****args += ",left="+ x +",screenX="+ x;
     *****args += ",top="+ y +",screenY="+ y;
     *}
     *window.open(url, "_blank", args);
    ****}
    </script>

Похожие темы

  1. open new window
    от 6X6 в разделе Веб-программирование
    Ответов: 3
    Последнее сообщение: 15.06.2007, 15:33
  2. Глюк с window.createPopup()
    от Krutoy в разделе Веб-программирование
    Ответов: 0
    Последнее сообщение: 28.02.2007, 03:54
  3. window.open
    от Aykroyd в разделе Веб-программирование
    Ответов: 4
    Последнее сообщение: 23.12.2006, 00:22
  4. Opera: Open in new tab
    от STING в разделе Вёрстка сайта
    Ответов: 5
    Последнее сообщение: 13.03.2006, 20:03
  5. Help New Window in PHP
    от nes1k в разделе Веб-программирование
    Ответов: 8
    Последнее сообщение: 05.09.2004, 02:59

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •