Переход на разные страницы.
Код:
<Script> function warp() {var ok=confirm('Нажмите "OK" и попадете ко мне на главную, "Cancel" - в мой магазин') if(ok) location="http://мой сайт.ru/" else location="http://мой сайт.ru"} </Script> <Form> <Input Name="B1" OnClick="warp()" Type="button" Value="ЖМИ"> </Form>
Приветствие,определение вашего броузера,кодировки и прихода на страницу.
Код:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Ваш браузер</title> </head> <body> <u><small><font color="#004080"><strong><script language="JavaScript"><!-- var h=(new Date()).getHours(); if (h > 4 && h < 12) document.writeln("Доброе утро!"); if (h > 11 && h < 18) document.writeln("Добрый день!"); if (h > 17 && h < 24) document. writeln("Добрый вечер!"); if (h > 23 || h < 5) document.writeln("Доброй ночи!"); // --></script></strong></font></small></u> <dl> <dt><font face="Times New Roman"><small>Ваш браузер: <font color="#004080"><strong><script language="JavaScript"> document.write(navigator.appName);</script></strong></font> <br> Версия вашего броузера: <font color="#004080"><strong><script language="JavaScript">document.write(navigator.appVersion);</script></strong></font> с разрешением экрана монитора <font color="#004080"><strong><script language="JavaScript"> <!-- if (self.screen) { // for NN4 and IE4 width = screen.width height = screen.height } else if (self.java) { // for NN3 with enabled Java var jkit = java.awt.Toolkit.getDefaultToolkit(); var scrsize = jkit.getScreenSize(); width = scrsize.width; height = scrsize.height; }else{ width = height = 'x' // for all other browsers } if (width == 640) { document.writeln('640x480') } else if (width == 800) { document.writeln('800x600') } else if (width == 1024) { document.writeln('1024x768') } else if (width == 1280) { document.writeln('1280x?') } else { document.writeln('I don`t know your resolution') } //--> </script></strong></font></small></font></dt> <dt><small><font face="Times New Roman">Ваша кодировка </font><font face="Times New Roman" color="#004080"><strong><script> var u=navigator.userAgent; if (u.indexOf("Win") != -1) // Текст в 1251 document.writeln ("Windows 1251") ; else if (u.indexOf("DOS") != -1 || u.indexOf("OS/2") != -1) // Текст в 866 document.writeln("MS-DOS CP866"); else // Текст в K018 document.writein ( "лПДЙТПЧЛБ KOI8-R") ; </script></strong></font></small></dt> <dt><font size="2" color="#000000" face="Times New Roman">А пришли вы к нам </font><font size="2" face="Times New Roman" color="#004080"><strong><script language="JavaScript"> var caution = false function setCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "") if (!caution || (name + "=" + escape(value)).length <= 4000) document.cookie = curCookie else if (confirm("Cookie exceeds 4KB and will be cut!")) document.cookie = curCookie } function getCookie(name) { var prefix = name + "=" var cookieStartIndex = document.cookie.indexOf(prefix) if (cookieStartIndex == -1) return null var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)) } function deleteCookie(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT" } } function fixDate(date) { var base = new Date(0) var skew = base.getTime() if (skew > 0) date.setTime(date.getTime() - skew) } var now = new Date() fixDate(now) now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000) var visits = getCookie("counter") if (!visits) visits = 1 else visits = parseInt(visits) + 1 setCookie("counter", visits, now) document.write("" + visits + "") </script></strong></font><font size="2" color="#000000" face="Times New Roman"> раз.</font></dt></body> </html>
Определение разрешения экрана монитора
Код:
Ваше разрешение: <SCRIPT LANGUAGE="JavaScript"><!-- S_width=screen.width;S_height=screen.height;// определение ширины и высоты document.write(S_width+'x'+S_height);// показывает результат //--></script>[/b] [align=center][b]Определение страницы с которой пришли к вам на сайт[/b][/align] [b]<head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title>Вы пришли сюда с...</title> </head> <body> <SCRIPT LANGUAGE="JavaScript"> var ref = document.referrer; if (ref == "") {var ref="неизвестной страницы"} document.write("Вы пришли сюда с "+ref) </SCRIPT> </body>
Калькулятор.
Код:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> </head> <body onload="start()"> <p><script language="JavaScript"><!-- function start() { document.memory = "" } document.memory = "" function myFunction3() { var myString3=""; if (confirm) document.myForm3.myText1.value = eval(document.myForm3.myText1.value); else document.myForm3.myText1.value = myString3; } function addchar(character, field) { field.value = field.value + character; } function delchar(field) { if (field.value.length != 0) { field.value = field.value.substring(0, field.value.length - 1); } } function clearfield(field) { field.value = ''; } function x2() { var myString3=""; if (confirm) document.myForm3.myText1.value = eval(document.myForm3.myText1.value*document.myForm3.myText1.value); else document.myForm3.myText1.value = myString3; } function Memory() { var memory = document.myForm3.myText1.value var empity = null document.empity = empity document.memory = memory if (document.empity = document.myForm3.myText1.value) { document.myForm3.m.value = "M"} else document.myForm3.m.value = "" } function ViewMemory(character, field) { field.value = field.value + document.memory; } function ClearMemory() { var clear ="" document.myForm3.m.value = "" document.memory = clear } // --></script></p> <form name="myForm3"> <div align="center"><center><table border="0"> <tr> <td width="100%"><div align="center"><center><table border="2" cellpadding="0" cellspacing="0" width="100%" bgcolor="#C0C0C0"> <tr> <td><div align="center"><center><p><font size="1" face="MS Sans Serif">Калькулятор 2.0<br> </font><font color="#400080" size="1" face="MS Sans Serif"></font></td> </tr> <tr> <td align="center" width="100%" bgcolor="#FF0000"><a class="s17"><font face="Arial Cyr, Arial, Times New Roman"><!--webbot bot="Validation" startspan s-display-name="onclick" s-data-type="Integer" s-number-separators="x" --><!--webbot bot="Validation" endspan --><input type="text" size="25" name="myText1" onfocus="this.blur()" style="font-family: sans-serif; text-transform: capitalize; text-align: right; background-color: rgb(255,0,0); color: rgb(255,255,255); border: medium none rgb(255,0,0)"></font></a><div align="center"><center><table border="2" cellpadding="0" cellspacing="0" bgcolor="#C0C0C0"> <tr> <td><div align="center"><center><p><input type="text" size="5" name="m" onfocus="this.blur()" style="font-family: MS Sans Serif; font-size: 8; background-color: rgb(255,255,0); color: rgb(0,0,0); text-align: center"></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" ¬ " onclick="delchar(this.form.myText1)" style="font-family: Symbol; color: rgb(128,0,0); border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" p " onclick="clearfield(this.form.myText1), addchar("3.1415926", this.form.myText1)" style="font-family: Symbol; color: rgb(128,0,0); border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" x*x " onclick="x2(this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; color: rgb(128,0,0); border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" ё " onclick="addchar("/", this.form.myText1)" style="font-family: Symbol; color: rgb(0,0,128); border: medium none rgb(192,192,192)"></font></td> </tr> <tr> <td align="center"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" C " onclick="clearfield(this.form.myText1)" style="color: rgb(255,0,0); font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 7 " onclick="addchar("7", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 8 " onclick="addchar("8", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 9 " onclick="addchar("9", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" ґ " onclick="addchar("*", this.form.myText1)" style="font-family: Symbol; color: rgb(0,0,128); border: medium none rgb(192,192,192)"></font></td> </tr> <tr> <td align="center"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" П " onclick="Memory(this.form.myText1)" style="color: rgb(0,0,255); font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 4 " onclick="addchar("4", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 5 " onclick="addchar("5", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 6 " onclick="addchar("6", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" - " onclick="addchar("-", this.form.myText1)" style="color: rgb(0,0,128); border: medium none rgb(192,192,192)"></font></td> </tr> <tr> <td align="center"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" ИП " onclick="ViewMemory("", this.form.myText1)" style="color: rgb(0,0,255); font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 1 " onclick="addchar("1", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 2 " onclick="addchar("2", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 3 " onclick="addchar("3", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" + " onclick="addchar("+", this.form.myText1)" style="color: rgb(0,0,128); border: medium none rgb(192,192,192)"></font></td> </tr> <tr> <td align="center"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" СП " onclick="ClearMemory(this.form.myText1)" style="color: rgb(255,0,0); font-family: MS Sans Serif; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" valign="top" width="25%" nowrap><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 00 " onclick="addchar("00", this.form.myText1)" style="font-family: MS; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" 0 " onclick="addchar("0", this.form.myText1)" style="font-family: MS; font-size: 8; border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" value=" , " onclick="addchar(".", this.form.myText1)" style="font-family: MS Sans Serif; font-size: 8; color: rgb(64,0,64); border: medium none rgb(192,192,192)"></font></td> <td align="center" width="25%"><div align="center"><center><p><font face="Arial Cyr, Arial, Times New Roman"><input type="button" name="myCheckBox1" value=" = " onclick="myFunction3()" style="color: rgb(0,0,128); border: medium none rgb(192,192,192)"></font></td> </tr> </table> </center></div></td> </tr> </table> </center></div></td> </tr> </table> </center></div> </form> <p align="center"> </p> <p align="center"> </p> </body> </html>
Смена фона сайта.
Код:
<Script Language="JavaScript"> document.write("<Center>"); document.write("<Form Name=\"Kolory\">"); document.write("<Select Name=\"schemesel\" OnChange=\"document.bgColor = this.options[selectedIndex].value\">"); document.write("<Option Value=\"ffffff\" selected>Белый"); document.write("<Option Value=\"0000ff\">Синий"); document.write("<Option Value=\"a0a0a0\">Серый"); document.write("<Option Value=\"e9e900\">Желтый"); document.write("<Option Value=\"a0a0ff\">Пурпур"); document.write("<Option Value=\"c70000\">Красный"); document.write("<Option Value=\"ffffa0\">Коричневый"); document.write("<Option Value=\"f0f0fa\">Стальной"); document.write("<Option Value=\"ff00ff\">Сиреневый"); document.write("<Option Value=\"00ffff\">Небесный"); document.write("</Select>"); document.write("</Form>"); document.write("</Center>"); </Script> <br> <P><font color="#0000ff">7 - Меню-1.</font></P> <br> <html> <style> .w {text-decoration: none;} .w:hover{ color:#0000ff; } </style> <script language="JavaScript"> b_name = navigator.appName; b_version = parseFloat(navigator.appVersion); if (b_name == "Netscape") { roll = 'no'; } else if (b_name == "Microsoft Internet Explorer" && b_version >= 4.0) { roll = 'yes'; } else { roll = 'no'; } if ( roll == 'yes') {window.document.ondblclick=menu window.document.onclick=menu2 function menu() {if (tab.style.display=='none') {tab.style.left=self.event.clientX-5+document.body.scrollLeft; tab.style.top=self.event.clientY-5+document.body.scrollTop; tab.style.display=''} } function menu2(){ if (tab.style.display == 'none') {var a=1;var b=2;a+b} else {tab.style.display='none'} } } </SCRIPT>
Таблица цветов интернета
Код:
<HTML> <HEAD> </HEAD> <BODY marginwidth="" marginheight="" topmargin="" leftmargin="" text="" link="" vlink="" alink=""> <Script Language="JavaScript"> clr=new Array('00','20','40','60','80','a0','c0','ff'); for (i=0;i<8;i++) {document.write("<table border=1 cellpadding=8>"); for (j=0;j<8;j++) {document.write("<tr>"); for (k=0;k<8;k++) {document.write('<td bgcolor="#'+clr[i]+clr[j]+clr[k]+'">'); document.write('<tt><font color="#'+clr[7-i]+clr[7-j]+clr[7-k]+'"> '); document.write(clr[i]+clr[j]+clr[k]+' </font></tt></td>');} document.write("</tr>");} document.write("</table><br>");} </Script> </BODY> </HTML>