- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <!-- saved from url=(0060)http://www.51javascript.net/free/Messages/demo/me11-demo.htm -->
- <HTML><HEAD><TITLE>可编辑菜单</TITLE>
- <META content="提供知识指南,相关参考资料,js 编辑器,即免费脚本" name=description>
- <META content=指南,参考资料,技术论坛,脚本 name=keywords>
- <META content="text/html; charset=gb2312" http-equiv=Content-Type>
- <SCRIPT language=JavaScript>
- <!-- Begin
- var o = null;
- var isNN = (navigator.appName.indexOf("Netscape")!=-1);
- function beginEditing(menu) {
- finish();
- if(menu[menu.selectedIndex].value != "read-only") {
- o = new Object();
- o.editOption = menu[menu.selectedIndex];
- o.editOption.old = o.editOption.text;
- o.editOption.text = "_";
- menu.blur();
- window.focus();
- document.onkeypress = keyPressHandler;
- }
- function keyPressHandler(e){
- var option = o.editOption;
- var keyCode = (isNN) ? e.which : event.keyCode;
- if(keyCode == 8 || keyCode == 37)
- option.text = option.text.substring(0,option.text.length-2) + "_";
- else if (keyCode == 13) {
- finish();
- } else
- option.text = option.text.substring(0,option.text.length-1) + String.fromCharCode(keyCode) + "_";
- status = keyCode;
- }
- function finish() {
- if(o != null) {
- option = o.editOption;
- if(option.text.length > 1)
- option.text = option.text.substring(0,option.text.length-1);
- else
- option.text = option.old;
- document.onkeypress = null;
- o = null;
- }
- }
- }
- // End -->
- </SCRIPT>
- <META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
- <BODY bgColor=#ffffff vLink=#0000ff>
- <DIV align=center><BR><BR><BR><BASEFONT><FONT face=Helvetica,Arial size=+2><FONT
- color=#0000ff><B>可编辑</B></FONT></FONT><FONT face=Helvetica,Arial size=+2><FONT
- color=#0000ff><B>菜单</B></FONT></FONT><BR><!-- Demonstration --></DIV>
- <CENTER>
- <FORM><SELECT οnchange=beginEditing(this); size=7> <OPTION
- value=read-only>Select an option to edit it.</OPTION> <OPTION
- value=read-only> ----------------------------
- </OPTION> <OPTION
- value=last>SurName</OPTION> <OPTION value=first>FirstName</OPTION> <OPTION
- value=email>Email</OPTION> <OPTION value=add1>Address 1</OPTION> <OPTION
- value=add2>Address 2</OPTION></SELECT> </FORM></CENTER>
- <P>
- <P>
- <P><A name=source></A>
- <CENTER><!--content_stop-->
- <P>
- <SCRIPT language=JavaScript>
- <!-- Begin
- function getCookieVal (offset) {
- var endstr = document.cookie.indexOf(";", offset);
- if (endstr == -1)
- endstr = document.cookie.length;
- return unescape(document.cookie.substring(offset, endstr));
- }
- function GetCookie (name) {
- var arg = name + "=";
- var alen = arg.length;
- var clen = document.cookie.length;
- var i = 0;
- while (i < clen) {
- var j = i + alen;
- if (document.cookie.substring(i, j) == arg)
- return getCookieVal (j);
- i = document.cookie.indexOf(" ", i) + 1;
- if (i == 0)
- break;
- }
- return null;
- }
- function SetCookie (name, value) {
- var argv = SetCookie.arguments;
- var argc = SetCookie.arguments.length;
- var expires = (argc > 2) ? argv[2] : null;
- var path = "/"; //(argc > 3) ? argv[3] : null;
- var domain = (argc > 4) ? argv[4] : null;
- var secure = (argc > 5) ? argv[5] : false;
- document.cookie = name + "=" + escape (value) +
- ((expires == null) ? "" : ("; expires=" +
- expires.toGMTString())) +
- ((path == null) ? "" : ("; path=" + path)) +
- ((domain == null) ? "" : ("; domain=" + domain)) +
- ((secure == true) ? "; secure" : "");
- }
- var emailcookie = GetCookie('email_address');
- if (emailcookie == null) {
- emailcookie = 'your email here';
- }
- function chk(email, formname)
- {
- invalid = "";
- if (!email)
- invalid = "No email address found! Try reloading the page then use the 'email a script' feature again.";
- else {
- if ( (email.indexOf("@") == -1) || (email.indexOf(".") == -1) )
- invalid += "/n/nInvalid email address. Your email address is missing an '@' sign and a '.' in the domain name (like '.com'). Please check your address then submit again.";
- if (email.indexOf("youremailhere") > -1)
- invalid += "/n/nInvalid email address. Make sure your email address included your username, the '@' sign, and the domain name (like '.com').";
- if (email.indexOf("//") > -1)
- invalid += "/n/nEmail address contains an invalid back-slash (//) character. Remove the character and submit again.";
- if (email.indexOf("/") > -1)
- invalid += "/n/nEmail address contains an invalid forward-slash (/) character. Remove the character and submit again.";
- if (email.indexOf("'") > -1)
- invalid += "/n/nEmail address contains an invalid apostrophe (') character. Remove the character and submit again.";
- if (email.indexOf("zaz.com.br") > -1)
- invalid += "/n/nPlease do not use an email address that has an autoresponder set up for it. Thanks.";
- if (email.indexOf("!") > -1)
- invalid += "/n/nEmail address contains an invalid exclamation point (!) character. Remove the character or correct the email address then submit again.";
- if ( (email.indexOf(",") > -1) || (email.indexOf(";") > -1) )
- invalid += "/n/nPlease only enter one email address in the box at a time. Remove the extra addresses and submit again.";
- if (email.indexOf("?subject") > -1)
- invalid += "/n/nPlease do not add '?subject=...' to your email address. Scriptbot will send you the script with a pre-defined subject already. Please remove the '?subject=...' from your email address and submit again.";
- }
- if (invalid == "")
- {
- var largeExpDate = new Date();
- largeExpDate.setTime(largeExpDate.getTime() + (31 * 24 * 3600 * 1000));
- SetCookie('email_address', email, largeExpDate);
- if (formname == "scriptbot")
- {
- page = "http://javascript.internet.com/sent.html?" + email;
- window.open(page, "AdWindow", "width=650,height=200");
- }
- return true;
- }
- else
- {
- alert("Oops, something is wrong...." + invalid);
- return false;
- }
- }
- function updateNewsletters() {
- with (document.forms["newslettersignup"]) {
- emailStr = email.value;
- var emailPat=/^(.+)@(.+)$/;
- var specialChars="//(//)<>@,;:///"//.//[//]"; // remove ( ) < > @ , ; : / " . [ ] */
- var validChars="/[^//s" + specialChars + "/]";
- var quotedUser="(/"[^/"]*/")";
- var ipDomainPat=/^/[(/d{1,3})/.(/d{1,3})/.(/d{1,3})/.(/d{1,3})/]$/;
- var atom=validChars + '+';
- var word="(" + atom + "|" + quotedUser + ")";
- var userPat=new RegExp("^" + word + "(//." + word + ")*$");
- var domainPat=new RegExp("^" + atom + "(//." + atom +")*$");
- var matchArray=emailStr.match(emailPat);
- if (matchArray==null) {
- alert("Email address seems incorrect (check @ and .'s)");
- return false;;
- }
- var user=matchArray[1];
- var domain=matchArray[2];
- if (user.match(userPat)==null) {
- alert("The username doesn't seem to be valid.");
- return false;
- }
- var IPArray=domain.match(ipDomainPat);
- if (IPArray!=null) {
- for (var i=1;i<=4;i++) {
- if (IPArray[i]>255) {
- alert("Destination IP address is invalid!");
- return false;
- }
- }
- }
- var domainArray=domain.match(domainPat);
- if (domainArray==null) {
- alert("The domain name doesn't seem to be valid.");
- return false;
- }
- var atomPat=new RegExp(atom,"g");
- var domArr=domain.match(atomPat);
- var len=domArr.length;
- if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
- alert("The address must end in a three-letter domain, or two letter country.");
- return false;
- }
- if (len<2) {
- var errStr="This address is missing a hostname!";
- alert(errStr);
- return false;
- }
- List_Name.value = newsletter.options[newsletter.selectedIndex].value
- + nltype.options[nltype.selectedIndex].value;
- var largeExpDate = new Date();
- largeExpDate.setTime(largeExpDate.getTime() + (31 * 24 * 3600 * 1000));
- SetCookie('email_address', emailStr, largeExpDate);
- return true;
- }
- }
- // End -->
- </SCRIPT>
- <CENTER></CENTER></CENTER>
- <SCRIPT language=JavaScript> </SCRIPT>
- </BASEFONT></BODY></HTML>
javascript 实现 select手动输入
最新推荐文章于 2023-02-06 16:55:13 发布