JavaScript примеры

1


<input id="hi" type="button" value="Нажми" onclick="confirm('Просто спрошу, как у тебя дела?');">

2


<input id="went" type="button" value="Open new window" onclick="window.open('https://blogprokirillhtml.blogspot.com/','popUpWindow','height=500, width=400, left=100, top=100, resizable=yes, scrollbars=yes, toolbar=yes, menubar=no, location=no, directories=no, status=yes');">

3


<p id="msg"></p>

<script>
  // Set variables
  var myBankBalance = 0;
  var output = "";

  // Do the 'while' loop
  while (myBankBalance <= 10) {
    output += "My bank balance is now $" + myBankBalance + "
";
    myBankBalance ++;
  }

  // Output results to the above HTML element
  document.getElementById("msg").innerHTML = output;
</script>

4


<script&ht;
// Wait for DOM to load
document.addEventListener("DOMContentLoaded", function(event) {

  // Put the button into a variable
  var e = document.getElementById("go");
  
  // Wait for user to click the button
  e.addEventListener("click", function() {
    
    // Get the URL from the user input
    var url = document.getElementById("url").value;
    
    // Do the popup window
    window.open(url,"popUpWindow","height=500, width=400, left=100, top=100, resizable=yes, scrollbars=yes, toolbar=yes, menubar=no, location=no, directories=no, status=yes");
    
  }, false);
  
});
</script>

<!-- Replace '{action page}' with your own action page to support non-JavaScript users -->
<form name="popupForm" action="{action page}">
  <input name="url"  id="url" value="https://blogprohtml.blogspot.com/">
  <input name="go" id="go" type="button" value="Go">
</form>

5


<time id="msg"></time>

<script>
  document.getElementById("msg").innerHTML = Date();
</script>

0 коммент.:

Отправить комментарий