Помогите с javascript

Discussion in 'PHP' started by kdk, 29 Sep 2009.

  1. kdk

    kdk Elder - Старейшина

    Joined:
    8 Nov 2006
    Messages:
    112
    Likes Received:
    5
    Reputations:
    -3
    index.html
    PHP:
    <html>
    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html;charset=cp-1251">
    <
    link rel="stylesheet" href="style.css" type="text/css">
    </
    head>
    <
    body>
    <
    a href="#" onclick="document.getElementById('wind').style.display='block'; return false;">Открыть окно</a>
    <
    div id="wind">
        <
    button type="button" value="закрыть" onclick="document.getElementById('wind').style.display='none'; return false;">
    закрыть</button>
    </
    div>
    </
    body>
    </
    html>
    style.css
    PHP:
    {
       
    text-decoration:none;
       
    color:#03508c;
       
    font-weight:bold;
       
    font-size:16px;
    }

    #wind {
           
    positionabsolute;
        
    width:320px;
        
    left35%;
          
    top100px;
        
    border:solid #105a98 4px;
        
    displaynone;
          
    z-index10;
        
    overflowhidden;
        
    background-color:#348c03;
        
    color:#fff;
        
    text-align:center;
        
    padding:10px;
    }
    Сразу сорри за дурацкий вопрос!
    Как не нажимая <a href="#" onclick="document.getElementById('wind').style.display='block'; return false;">Открыть окно</a> окошко сразу появлялось на странице!
    СПС!
     
  2. preda1or

    preda1or Member

    Joined:
    27 Oct 2008
    Messages:
    167
    Likes Received:
    96
    Reputations:
    6
    Code:
    <html>
        <body onload='document.getElementById("wind").style.display="block"'>
        </body>
    </html>
    или

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=cp-1251">
    <link rel="stylesheet" href="style.css" type="text/css">
    <script type="text/javascript">
    document.getElementById("wind").style.display="block";
    </script>
    </head>
    <body>
    <div id="wind">
        <button type="button" value="закрыть" onclick="document.getElementById('wind').style.display='non  e'; return false;">
    закрыть</button>
    </div>
    </body>
    </html>  
     
    #2 preda1or, 29 Sep 2009
    Last edited: 29 Sep 2009
  3. kdk

    kdk Elder - Старейшина

    Joined:
    8 Nov 2006
    Messages:
    112
    Likes Received:
    5
    Reputations:
    -3
    PHP:
    <html>
    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html;charset=cp-1251">
    <
    link rel="stylesheet" href="style.css" type="text/css">
    <
    script type="text/javascript">
    document.getElementById("wind").style.display="block";
    </script>
    </head>
    <body>
    <div id="wind">
        <button type="button" value="закрыть" onclick="document.getElementById('wind').style.display='non    e'; return false;">
    закрыть</button>
    </div>
    </body>
    </html> 
    Можешь еще раз ответь почему у меня
    <script type="text/javascript">
    document.getElementById("wind").style.display="block";
    </script>
    Вот эта часть не пашет???
     
    #3 kdk, 29 Sep 2009
    Last edited: 29 Sep 2009
  4. kdk

    kdk Elder - Старейшина

    Joined:
    8 Nov 2006
    Messages:
    112
    Likes Received:
    5
    Reputations:
    -3
    Может подскажите????
     
  5. astrologer

    astrologer Elder - Старейшина

    Joined:
    30 Aug 2007
    Messages:
    837
    Likes Received:
    267
    Reputations:
    59
    Она работает ровно так, как должна. Непонятно только, зачем вообще этот код, если достаточно в стилях поменять
    Code:
    display: none;
    на
    Code:
    display: block;
     
  6. kdk

    kdk Elder - Старейшина

    Joined:
    8 Nov 2006
    Messages:
    112
    Likes Received:
    5
    Reputations:
    -3
    Все равно у меня не появляеться окошко при загрузке!=((
     
  7. astrologer

    astrologer Elder - Старейшина

    Joined:
    30 Aug 2007
    Messages:
    837
    Likes Received:
    267
    Reputations:
    59
    Code:
    <!doctype html>
    <html>
    <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <title>О,кошко</title>
      <style>
    
      .wind
      {
        position: absolute;
        width: 320px;
        left: 35%;
        top: 100px;
        border: #105a98 solid 4px;
        display: block;
        z-index: 10;
        overflow: hidden;
        background-color: #348c03;
        color: #fff;
        text-align:center;
        padding: 10px;
      }
    
      </style>
    </head>
    <body>
      <div class="wind">Удивительно</div>
    </body>
    </html>