Recomendado: ASP genera código básico de la página HTM estática Manual de referencia oficial, Manual técnico autorizado Descargar la clasificación del tutorial de libros electrónicos El siguiente cuadro punteado es el código específico del archivo mk.asp: ----------------------- -------------------------------------------------- ---------------------- ---------------------------- ---------------------- -----
Recientemente estoy trabajando en un proyecto AJAX, que utiliza muchos bloqueos de pantalla simulados con una capa de pantalla completa, pero hay un dolor de cabeza, es decir, el cuadro de lista desplegable siempre se mostrará en la capa. , Escribí esta clase JS.
Vista previa del efecto:
Código de programa:
| El siguiente es el contenido citado: <html> <Evista> <meta http-oquiv = content-type content = text /html; <title> js div simula los elementos de forma seleccionados </title> <Script Language = JavaScript> seloptions = { Nombre: Seloptions, // Este es el nombre de la matriz Datos: New Array () } seloptions.data [0] = nueva matriz (0, opción 0) seloptions.data [1] = nueva matriz (1, opción1) seloptions.data [2] = new Array (2, opción2) seloptions.data [3] = nueva matriz (3, opción 3) seloptions.data [4] = nueva matriz (4, opción 4) seloptions.data [5] = nueva matriz (5, opción 5) seloptions.data [6] = nueva matriz (6, opción 6) seloptions.data [7] = nueva matriz (7, opción 7) seloptions.data [8] = nueva matriz (8, opción 8) seloptions.data [9] = nueva matriz (9, opción 9) seloptions.data [10] = nueva matriz (10, opción10) seloptions.data [11] = nueva matriz (11, opción11) seloptions.data [12] = New Array (12, opción12) seloptions.data [13] = nueva matriz (13, opción13) seloptions.data [14] = nueva matriz (14, opción14) seloptions.data [15] = nueva matriz (15, opción15) tmhselect = { // función principal // Significado del parámetro: Contenedor, nombre, datos [Array], elemento predeterminado, ancho, acción (la función objetivo no puede tener parámetros) Show: function (obj, selectName, dataBj, seloption, ancho, acción) { var data = dataObj.data; var _obj = document.getElementById (obj); if (! _ obj || typeof (_obj) == Undefined) {return false;} var s1 = document.createElement (div); if (isnan (ancho) || ancho ==) {width = 150;} else if (ancho <26) {width = 26;} s1.style.width = ancho; s1.onMouseLeave = function () {tmhselect.hidden (selectName)}; var str =; // juzga si hay algún dato if (data.length> 0) { // Muestra la lista de opciones de datos cuando hay datos str = <input type = 'Hidden' name = 'selectName' id = 'selectName' value = 'tmhselect.relv (seloption, data)'>; str = <div id = '_ a_ selectName' style = 'Width: Width Px; Height: 18px; str = <div id = '_ v_ selectName' style = 'posición: relativo; float: izquierda; izquierda: 2px; ancho: (ancho-22) px; altura: 18px; font-size: 12px; desbordamiento: oculto; línea- altura: 18px; ' str = <div style = 'posición: relativo; float: derecha; derecha: 0px; ancho: 18px; altura: 18px; text-aline -color: #cccccc; cursor: puntero! importante; cursor: hand; ' str = </div>; str = <div id = '_ b_ selectName' style = 'Position: Absolute; X: Oculto; desbordamiento: Auto; Pantalla: Ninguno; para (i = 0; i <data.length; i) { str = <div id = '_ s_ selectName' style = 'tmhselect.style (1, data [i] [0], seloption)' onmouseover =/tmhselect.css (2, this, 'data [i] [0]' , 'selectName')/ onMouseOut =/ tmhselect.css (1, this, 'data [i] [0]', 'selectName')/ onClick =/ tmhselect.selected (this, 'data [i] [0]' ' , dataBj.name, 'Action')/> Data [i] [1] </div>; } str = </div>; }demás{ // se muestra una forma vacía cuando no hay datos str = <input type = 'Hidden' name = 'selectName' id = 'selectName' value = 'SelOption'>; str = <div id = '_ a_ selectName' style = 'Width: Width Px; Height: 18px; str = <div id = '_ v_ selectName' style = 'posición: relativo; float: izquierda; izquierda: 2px; ancho: (ancho-22) px; altura: 18px; font-size: 12px; desbordamiento: oculto; línea- altura: 18px; ' str = <div style = 'posición: relativo; float: derecha; derecha: 0px; ancho: 18px; altura: 18px; text-aline -color: #cccccc; cursor: puntero! importante; cursor: hand; ' str = </div>; str = <div id = '_ b_ selectName' style = 'Position: Absolute; oculto; desbordamiento: auto; visualización: ninguno; } s1.innerhtml = str; _Obj.appendChild (S1); }, // devuelve el valor del elemento seleccionado valor: function (n) {return document.getElementById (n) .value;}, // Devuelve el texto del elemento seleccionado Text: function (n) {return document.getElementById (_v_ n) .innertext;}, seleccionado: función (o, v, dn, acción) { var d = dn.data; var n = o.id.replace (/(_ s _)/gi,) document.getElementById (n) .value = v; document.getElementById (_v_n) .innerhtml = tmhselect.restr (d, v); tmhselect.showOptions (n) for (var i = 0; i <document.getElementById (_b_n) .childnodes.length; i) { document.getElementById (_b_n) .childnodes [i] .style.csstext = tmhselect.style (1) } o.style.csstext = tmhselect.style (2); if (acción! = && action! = null) { Prueba {eval (acción)} catch (e) {} } }, relv: function (v, d) { para (i = 0; i <d.length; i) { if (d [i] [0] == v) { regreso v; } } if (v == null || v ==) { return d [0] [0]; } }, RIST: FUNCIÓN (D, M) { para (i = 0; i <d.length; i) { if (d [i] [0] == m) { return d [i] [1]; } } if (m == null || m ==) { return d [0] [1]; } }, Altura: función (l) {var h; if (l> 10 || l <1) h = 10 * 15; showOptions: function (n) { var o = document.getElementById (_b_n) if (o.style.display == ninguno) o.style.display =; demás o.style.display = none; _SelectOptionselm = o; }, oculto: function (n) { document.getElementById (_b_n) .style.display = none; }, Estilo: función (m, v1, v2) { var cs =; if (v1 == v2 && v1! = && v1! = null) {m = 2;} Switch (m) { Caso 1: CS = Altura: 15px; romper; Caso 2: CS = Altura: 15px; romper; } devolver CS; }, CSS: function (s, obj, v, n) { var v1 = document.getElementById (n) .Value; if (v == v1) { obj.style.csstext = tmhselect.style (2); devolver; }demás{ obj.style.csstext = tmhselect.style (s) } } } función test () { alerta (tmhselect.value ('test')); } </script> </ablo) <Body> <div id = testDiv> </div> <Br /> <Entrada type = button name = button value = Ver text onClick = alert (tmhselect.text ('test')) /> <input type = button name = button value = Ver opción Valor OnClick = Alert (tmhselect.value ('test')) /> <Script Language = JavaScript> tmhselect.show (testDiv, test, seloptions ,, 160, test ()); </script> </body> </html> |
Compartir: caracteres chinos de ASP a Pinyin, admite palabras especiales personalizadas Esta vez actualicé el programa de blog que solía usar, y usé el nombre del archivo al generar archivos estáticos para usar el Pinyin del título del artículo, esto implica cómo convertir el texto en Pinyin. Solo debe ser normal bajo GB2312, y no hay