За последние 24 часа нас посетили 34155 программистов и 1709 роботов. Сейчас ищут 766 программистов ...

неработает self.close()

Тема в разделе "JavaScript и AJAX", создана пользователем riaron, 27 май 2015.

  1. riaron

    riaron Активный пользователь

    С нами с:
    1 окт 2014
    Сообщения:
    247
    Симпатии:
    4
    self.close в buttone со свойствами submit неработает
    Вот код
    Код (Text):
    1. <script type="text/javascript">
    2. name = 'Это я его открыло!';
    3. var win; /* НОВОЕ ОКНО! */
    4.  
    5. function winOpen() {
    6.     var w = 300, h = 500,
    7.             l = (screen.width - w) / 2,
    8.             t = (screen.height - h) / 2,
    9.             p = "width="+w+", height="+h+", top="+t+", left="+l;
    10.     win = window.open("", "", p);
    11.     win.focus();   
    12.     docWrite()
    13. }
    14. function winClose() {
    15.     if( win && !win.closed ){
    16.         win.focus();
    17.         win.close();
    18.     }  
    19. }
    20. function docWrite() {
    21.     if( win && !win.closed ){
    22.         win.focus();
    23.         var text = "";
    24.         text+='<div class="orderForm" style="left:0px;top:0px;background:blue;">';
    25.         text+='<form action="mail.php" method="post">';
    26.         text+='<fieldset>';
    27.         text+='<link rel="stylesheet" href="css/style.css">';
    28.         text +='<p><label for="name">Имя*</label></p>';
    29.         text+='<p><input type="text" name="name" id="name" required></p>';
    30.         text +='<p><label for="city">Город</label></p>';
    31.         text+='<p><input type="text" name="city" id="city"></p>'
    32.         text +='<p><label for="email">E-mail*</label></p>';
    33.         text+='<p><input type="email" name="email" id="email" required></p>'
    34.         text +='<p><label for="phone">Телефон*</label></p>';
    35.         text+='<p><input type="text" name="phone" id="phone" required></p>';
    36.         text +='<p><label for="company">Сайт компании</label></p>';
    37.         text+='<p><input type="text" name="site" id="company"></p>';
    38.         text+='<button class="btn btn-primary btn-lg" type="submit" value="Отправить" name="submit" href="javascript:self.close();">Отправить заявку</button>';
    39.         text+='</fieldset>';
    40.         text+='</form>';
    41.         text+='</div>';
    42.         win.document.open();
    43.         win.document.write(text);
    44.         win.document.close();
    45.     }
    46.  
    47. </script>
    48. </head>
    49. <body>
    50. <p class="p1"><a href="javascript:winOpen();">Открыть окно</a></p>
    51. <p class="p3"><a href="javascript:docWrite();">Заполнить окно</a></p>
    52. <p class="p2"><a href="javascript:winClose();">Закрыть окно</a></p>
    53. </body>
    54. </html>
    как исправить