This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Методы объекта String | |
var str="Hello world!"; | |
document.write(str.length); | |
document.write("<p>Bold: " + str.bold() + "</p>"); | |
document.write("<p>Italic: " + str.italics() + "</p>"); | |
document.write(str.match("world") + "<br />"); | |
document.write(str.match("World") + "<br />"); | |
document.write(str.indexOf("Hello") + "<br />"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Поиск подстроки | |
var birthDate = /(\d+)\.(\d+)\.(\d+)/.exec("Я родился 21.05.1958"); | |
document.write("Дата рождения: ", birthDate[0], " "); | |
document.write("День рождения: ", birthDate[1], " "); | |
document.write("Месяц рождения: ", birthDate[2], " "); | |
document.write("Год рождения: ", birthDate[3], " "); | |
// 2. Модификаторы |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getTaxiFare(len, hour) { | |
var price = 200, | |
nightTax = 0.3; | |
if (len < 10) { | |
len = 10; | |
} | |
if (hour < 1 || hour > 24) { | |
return alert('В сутках только 24 часа!'); | |
} | |
total = len * price; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initArray() { | |
this.length = initArray.arguments.length; | |
for (var i = 0; i < this.length; i++) | |
this[i] = initArray.arguments[i]; | |
} | |
var myFriends = new initArray("Михаил", "Максим", "Сергей", "Леонид"); | |
alert(myFriends.length); | |
alert(myFriends[0]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type=”text/javascript”> | |
function yourMessage(){ | |
alert("Функция"); | |
} | |
</script> | |
</head> | |
<body onload="yourMessage()"> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript"> | |
var txt=""; | |
function message() { | |
try { | |
adddlert("Welcome guest!"); | |
} | |
catch(err) { | |
txt="Ошибка на странице.\n\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function openWin() { | |
myWindow = window.open("", "", "width=200,height=100"); | |
myWindow.document.write("Вот оно - 'myWindow'!"); | |
myWindow.focus(); | |
myWindow.opener.document.write("Это окно, из которого открыли новое окно"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (i=1; i<=6; i++) { | |
document.write('<h'+i+'>Заголовок '+i.toString().italics()+' уровня</h'+i+'>'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Перезагрузка страницы</title> | |
<script type="text/javascript"> | |
function reloadPage() { | |
window.location.reload(); | |
} | |
</script> | |
</head> | |
<body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<input type=button value="Назад" onclick="history.back()"> | |
</form> |