2017-09-26 133 views
1

我最近設計了一個網頁,我不是一個網頁開發人員,所以我收集了來自不同地點的碎片和碎片,並將它們縫合起來。按鈕不工作在iPhone上的Safari瀏覽器

現在,該頁面已完全設計,並在Firefox,Chrome和IE中工作。

但它不適用於Safari。

下面是代碼:

<!DOCTYPE html> 
<html lang="en-US"> 

<head> 
<meta name="referrer" content="origin"> 
<script> 
    var counter = 0; 
    var limit = 50; 

    function addInput(divName, arrName){ 
     if (counter == limit) { 
       alert("You have reached the limit of adding " + counter + " inputs"); 
     } 
     else { 
       var newdiv = document.createElement('div'); 
       newdiv.innerHTML = "<input type='text' name='" + arrName + "[]' required>"; 
       document.getElementById(divName).appendChild(newdiv); 
       counter++; 
     } 
    } 

</script> 

<style> 
    html * 
    { 
     color: #000 !important; 
     font-family: Arial !important; 
    } 

.wrapper 
    { 
     height: 100%; 
     width: 100%; 
     display: flex; 
     overflow:auto; 

    } 

    .window 
    { 
     width: 100%; 
     min-height: 200px; 
     display: flex; 
     flex-direction: column-reverse; 
     float: none; 
     align-items: center; 
     justify-content: center; 

    } 

    .windowContent 
    { 

    } 

input[type=text], select { 
    width: 150%; 
    padding: 6px 10px; 
    margin: 4px 20px; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    box-sizing: border-box; 
} 

input[type=submit] { 
    width: 80%; 
    background-color: #4CAF50; 
    color: white; 
    padding: 14px 20px; 
    margin: 8px 0; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
} 
input[type=button]{ 
    width: 50%; 
    background-color: #9CAFFF; 
    color: white; 
    padding: 6px 5px; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
} 

input[type=submit]:hover { 
    background-color: #45a049; 
} 

div { 
    border-radius: 5px; 
    background-color: #f2f2f2; 
    padding: 0px; 
    float: left; 
    width: 75%; 
    margin: 5px; 
    margin-left: 0.5cm; 
} 

.floating-box { 
    float: left; 
    width: 100%; 
    margin: 5px; 
    margin-left: 0.5cm; 
    border: 3px solid #73AD21; 
} 


</style> 
</head> 

<body onload="GenerateEmotion()"> 
<div class="wrapper"> 
    <div class="window"> 
     <div class="windowContent"> 
      <form method="POST" action="http://formspree.io/[email protected]" align="center"> 
       <div id = "dynamicInputHolder"> 
        <div id="dynamicInput_1"> 
         Emotion: <input type="text" value="" name="myInputs_1[]" id="emotion" disabled> 
          <div class="floating-box">Its John and Sally's wedding day! John and Sally are getting ready wedding ceremony will begin in an hour. Sally is little nervous.</div> 
        </div> 
        <input type="button" value="Add connecting sentences" onClick="addInput('dynamicInput_1', 'myInputs_1');"> 
       </div> 

       <div id = "dynamicInputHolder"> 
        <div id="dynamicInput_2"> 
          <div class="floating-box">Sally heard a knock on the door.</div> 
        </div> 
        <input type="button" value="Add connecting sentences" onClick="addInput('dynamicInput_2', 'myInputs_2');"> 
       </div> 

       <div id = "dynamicInputHolder"> 
        <div id="dynamicInput_3"> 
          <div class="floating-box">Her heartbeat fast, Sally began to walk down the aisle.</div> 
        </div> 
        <input type="button" value="Add connecting sentences" onClick="addInput('dynamicInput_3', 'myInputs_3');"> 
       </div> 

       <br> 
       <input type="submit" value="I have completed a story"> 
      </form> 
      <script> 
       function GenerateEmotion(){ 
        var emotion = ""; 
        var raw = Math.random(); 
        var final = Math.ceil(raw * 4); 
        if (final == 1) 
         document.getElementById("emotion").value = "Happy"; 
        else if (final == 2) 
         document.getElementById("emotion").value = "Sad"; 
        else if (final == 3) 
         document.getElementById("emotion").value = "Angry"; 
        else if (final == 4) 
         document.getElementById("emotion").value = "Surprise"; 
       } 
      </script> 

     </div> 
    </div> 

    <div class="window"> 
     <div class="windowContent"> 
      <p><font size="6"><b>Emotionalize it!</b></font></p> 
      <p><font size="3">We are trying to develop computer programs that can understand common emotions, so they can communicate better with human users.</font></p> 
      <p><font size="5"><b> Rules of the game </b></font></p> 


      <font size="3"> 
      <p>Imagine you are a narrator. Today, you are narrating a story of John and Sally's wedding.</p> 
      <p>Your goal is to make your audience experience the emotion written on the left top. </p> 
      <p>We are helping you to maintain the flow, you just need to connect the dots!</p> 
      <p>As your story will be fed to a giant computer program, so can you:</p> 
      <ul> 
       <li>Please use simple language. Do NOT use compound, complex, or conditional sentences</li> 
       <li>Please do not use pronouns. Use the name - John instead of 'him'</li> 
       <li>Please use the past tense and active voice.</li> 
       <li>Please make sure to include events from the beginning to the end.</li> 
       <li>You want more characters? If yes, Please use David(male) and Amy(female)</li> 
       <li>You can use the also include character based actions, e.g. 'A waiter ...'</li> 
       <li>Your audiance should experience the said emotion</li> 
      </ul> 
      </font> 
     </div> 
    </div> 
</div> 

</body> 

</html> 

具體來說,什麼行不通:

  1. 按鈕,點擊 '添加新的句子'
  2. 提交

是否有任何錯誤:沒有,按下按鈕後沒有任何反應

我尋找出來:

  1. 如果你的Web開發人能弄清楚爲什麼它不Safari上工作,這將是很大的幫助。
  2. 如何更改該部分,所以功能仍然相同,但它在Safari上的工作原理
  3. 因爲我已經問過這個問題,另一方面的問題會有所幫助。我可以知道如何修復底部的滾動條嗎?

PS_1:如果你不喜歡複製粘貼此代碼,它是在工作狀態here

PS_2:當我說Safari瀏覽器,我的意思是在iPhone

+0

您應該創建[mcve],而不是將整個頁面轉儲到問題中。 – Quentin

+1

您的HTML中有一些機器可檢測到的錯誤。使用[驗證器](https://validator.nu)。 – Quentin

回答

1

嘗試將 「情感」 文本框中輸入了 「dynamicInput_1」 分區之外。因此,而不是:

 <form method="POST" action="http://formspree.io/[email protected]" align="center"> 
      <div id = "dynamicInputHolder"> 
       <div id="dynamicInput_1"> 
        Emotion: <input type="text" value="" name="myInputs_1[]" id="emotion" disabled> 
         <div class="floating-box">Its John and Sally's wedding day! John and Sally are getting ready wedding ceremony will begin in an hour. Sally is little nervous.</div> 
       </div> 
       <input type="button" value="Add connecting sentences" onClick="addInput('dynamicInput_1', 'myInputs_1');"> 
      </div> 

嘗試:用相同的ID div class vs id 您收到幾個div的:

 <form method="POST" action="http://formspree.io/[email protected]" align="center"> 
      <div id = "dynamicInputHolder"> 
      Emotion: <input type="text" value="" name="myInputs_1[]" id="emotion" disabled> 
       <div id="dynamicInput_1"> 
         <div class="floating-box">Its John and Sally's wedding day! John and Sally are getting ready wedding ceremony will begin in an hour. Sally is little nervous.</div> 
       </div> 
       <input type="button" value="Add connecting sentences" onClick="addInput('dynamicInput_1', 'myInputs_1');"> 
      </div> 

而且,看看使用id和class的這種解釋。 ID應該是唯一的。

我不確定你在底部固定滾動條的意思,所以我沒有解決這個問題。

+0

謝謝親切的陌生人! – Adorn

相關問題