10/10/06, 05:09:27
|
#241 (permalink)
|
Registrado: ene 2005
Mensajes: 279
|
USANDO Y MANEJANDO ACTIVEX I
P1: Notas.
ActiveX es una tenología que permite utilizar objetos OLE dentro de páginas web, siendo creados por Microsoft y siendo válidos desde la versión 3.0 del IE.
Es una tecnología que en el mundo web está bastante mal usada, y es la fuente de incursión de muchos tipos de datos peligrosos en nuestro PC por tener acceso al sistema de fichero de la persona que ejecuta el ActiveX, por lo que por seguridad siempre se encuentra desactivada la opción de ejecutar ActiveX. No obstante, los antivirus y antytroyanos ayudan a que ningún código peligros pudiera entrar.
No obstante, tiene sus ventajas el acceder a dichas propiedades de la colección de ActiveX, y yo, voy a poner algún ejemplo de ello.
-------------------------------
P2: Apertura, Lectura y Cierra de un fichero.
La función a la que llamaremos es:
Código PHP:
function lecturaActiveX(directorio,archivo) { // Creamos objeto a la librería FileSystemObject var objSystem = new ActiveXObject("Scripting.FileSystemObject"); // Comprobamos que el directorio exista if (fso.folderexists(directorio) == false) return false; else { var rutaCompleta = directorio + fichero; // Comprobamos que el fichero exista if(objSystem.FileExists(rutaCompleta ) == false) return false; else { // Abrimos el fichero con la ruta seleccionada var objFichero = objSystem.OpenTextFile(rutaCompleta ,1); // Método para leer el contenido del fichero var datosFichero = objFichero.readall(); // Cierra de fichero objFichero.close(); // Envío de la información, por ejemplo a un TextArea return datosFichero ; } } }
Nota: Si en el directorio ponemos la ruta de nuestro PC con la barra "\" nos dará error, tenemos que escapar esa barra con "\\".
-------------------------------
P3: Apertura, Modificación y Cierre de un fichero.
Ahora lo mismo, pero modificando la información de un fichero con alguna nueva, es decir, haciendo una operación de agregación de datos, esta vez pondré un ejemplo tal cual tengo en un HTML:
Código PHP:
function guardadoInfo() // Arreglo temporal con ActiveX para guardar el codigo en el fichero modo = 1; // Esta línea la podéis quitar :P rutaCompleta = rTrim(app.replace(/Ç/g, '\\')) + nomFich; // Creamos objeto FileSystemObject var fso = new ActiveXObject("Scripting.FileSystemObject"); // Caso de que no exista el fichero if(fso.FileExists(rutaCompleta) == false && modo==0) return false; // Si estamos en modo append guardamos todo el contenido del fichero if(fso.FileExists(rutaCompleta) != false && modo==2) { fich = fso.OpenTextFile(rutaCompleta,1); temporal = fich.readall(); fich.close(); } else temporal = ""; // Objeto para crear un nuevo fichero con la info del antiguo más lo que queremos agregar fich = fso.CreateTextFile(rutaCompleta,2); // Escribimos dicho contenido en el objeto fich fich.write(temporal + document.getElementById("codigo").innerText); // Cierra del fichero fich.close(); }
-------------------------------
P4: Ejecución de comandos mediante ActiveX.
Código PHP:
function ejecutaComando() { // Creamos objeto shell var objShell= new ActiveXObject("WScript.Shell"); // Parámetro 1 -> Ruta: Ruta completa con el comando a ejecutar // Parámetro 2 -> Modo: 0: Oculto, 1: normal, 2: minimizado, 3: maximizado, 4: normal sin foco // Parámetro 3 -> Instancia: false:Múltiples instancias, true: Solo una. var ejecuta = objShell.run("C:\\ARCHIV~1\\OFFICE\\WORD.EXE, 2, true); return ejecuta; }
-------------------------------
Como véis, lo que se puede hacer es realmente grande, pero exige que el administrador de la máquina tiene una configuración bien realizada para que solamente ejecute ActiveX de confianza, bien de una determinada web, o bien de una determinada intraner, o bien de un determinado grupo de dominios.
Saludos
__________________
:cool: [ http://eruben.sytes.net ] :cool:
Las dos frases que te ayudarán a salir adelante:No hay mujer fea, solo copas de menos. :borracho:
Ante la duda, siempre coge la más tetuda. :arriba:
|
|
|
|
15/10/06, 18:24:15
|
#242 (permalink)
|
Registrado: feb 2005
Ubicación: Veracruz
Mensajes: 1.174
|
P: Desactivar click derecho a las imágenes.
R: Con un poco de javascript esto es posible.
Código PHP:
<script language="JavaScript1.2">
var mensajealclick="El click derecho no esta permitido!"
function desactivarclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(mensajealclick);
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
alert(mensajealclick);
return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(mensajealclick)
return false
}
}
}
function imagenesasociadas(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=desactivarclick;
}
if (document.all)
document.onmousedown=desactivarclick
else if (document.getElementById)
document.onmouseup=desactivarclick
else if (document.layers)
imagenesasociadas()
</script>
__________________
<?php $var = "PHP is life"; ?>
|
|
|
|
27/10/06, 02:17:28
|
#243 (permalink)
|
|
Moderador extraterrestre
Registrado: nov 2002
Ubicación: Madrid
Mensajes: 6.783
|
añadir, cambiar y quitar opciones de un select
P.-¿Como añadir, cambiar y quitar opciones de un select por medio de javascript?
R.- Ver este hilo.
__________________
Experto: persona que ha cometido todos los errores que se pueden cometer en un determinado campo.
No visites mi blog.
|
|
|
|
28/10/06, 07:54:49
|
#244 (permalink)
|
|
Colaborador
Registrado: may 2004
Mensajes: 1.094
|
245.-Sencillo editor bbCode
P:Cómo hacer un editor de bbCode sencillo que admita selección de texto?
R:
Código:
<html>
<head>
<title>Editor bbCode</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function instag(tag){
var input = document.form1.contenido;
if(typeof document.selection != 'undefined' && document.selection) {
var str = document.selection.createRange().text;
input.focus();
var sel = document.selection.createRange();
sel.text = "[" + tag + "]" + str + "[/" +tag+ "]";
sel.select();
return;
}
else if(typeof input.selectionStart != 'undefined'){
var start = input.selectionStart;
var end = input.selectionEnd;
var insText = input.value.substring(start, end);
input.value = input.value.substr(0, start) + '['+tag+']' + insText + '[/'+tag+']'+ input.value.substr(end);
input.focus();
input.setSelectionRange(start+2+tag.length+insText.length+3+tag.length,start+2+tag.length+insText.length+3+tag.length);
return;
}
else{
input.value+=' ['+tag+']Reemplace este texto[/'+tag+']';
return;
}
}
function inslink(){
var input = document.form1.contenido;
if(typeof document.selection != 'undefined' && document.selection) {
var str = document.selection.createRange().text;
input.focus();
var my_link = prompt("Enter URL:","http://");
if (my_link != null) {
if(str.length==0){
str=my_link;
}
var sel = document.selection.createRange();
sel.text = "[a href=\"" + my_link + "\"]" + str + "[/a]";
sel.select();
}
return;
}else if(typeof input.selectionStart != 'undefined'){
var start = input.selectionStart;
var end = input.selectionEnd;
var insText = input.value.substring(start, end);
var my_link = prompt("Enter URL:","http://");
if (my_link != null) {
if(insText.length==0){
insText=my_link;
}
input.value = input.value.substr(0, start) +"[a href=\"" + my_link +"\"]" + insText + "[/a]"+ input.value.substr(end);
input.focus();
input.setSelectionRange(start+11+my_link.length+insText.length+4,start+11+my_link.length+insText.length+4);
}
return;
}else{
var my_link = prompt("Ingresar URL:","http://");
var my_text = prompt("Ingresar el texto del link:","");
input.value+=" [a href=\"" + my_link + "\"]" + my_text + "[/a]";
return;
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<input type="button" name="Submit" value="B" onClick="instag('b')">
<input type="button" name="Submit3" value="U" onClick="instag('u')">
<input type="button" name="Submit4" value=" I " onClick="instag('i')">
<input type="button" name="Submit2" value="LINK" onClick="inslink()">
<br>
<textarea name="contenido" cols="40" rows="10" id="contenido"></textarea>
</form>
</body>
</html>
Y algo más completo, en este enlace: bebecode
|
|
|
|
06/11/06, 13:00:32
|
#245 (permalink)
|
Registrado: oct 2004
Mensajes: 404
|
Rotador de Banners que acepta swf, gif y texto.
P: ¿Cómo puedo realizar un rotador de banners que acepte swf, gif y texto?
R: Aqui tienes un script que funciona perfectamente!!!
Creditos: Realizado por Fabian Muller y modificado por "djreficul" y una pequeña ayuda de "paulkees" para ForosdelWeb.com
Código HTML:
<html> <head> <title>Selección de Banners Aleatorios</title> </head> <body> <SCRIPT LANGUAGE="JavaScript"> // Realizado por: Fabian Muller y modificado por "djreficul" y una muy pequeña ayudita de "paulkees" de ForosdelWeb.com // Comienzo var banners = 3; var ahora = new Date() var segundos = ahora.getSeconds() var ad = segundos % banners; ad +=1; if (ad==1) { flash="images/banners/240x74_anuncio.swf" width="295"; height="90"; } if (ad==2) { flash="images/bantrigoban.gif" width="289"; height="100"; url="http://www.rawk.com.ar"; txt="¡Conoce rawk.com.ar ahora!"; } if (ad==3) { flash="images/banners/foros_295x80.swf" width="295"; height="80"; } temp=flash.split("."); extension=temp[(temp.length-1)]; document.write('<center>'); if (extension=='swf') { document.write('<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=' + width + ' height=' + height + ' CODEBASE=\"http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0\">'); document.write('<PARAM NAME=\"MOVIE\" VALUE=\"' + flash + '\">'); document.write('<PARAM NAME=\"PLAY\" VALUE=\"true\">'); document.write('<PARAM NAME=\"LOOP\" VALUE=\"true\">'); document.write('<PARAM NAME=\"QUALITY\" VALUE=\"high\">'); document.write('<EMBED SRC=' + flash + ' width=' + width + ' height=' + height + ' PLAY=\"true\" LOOP=\"true\" QUALITY=\"high\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=ShockwaveFlash\">'); document.write('</EMBED>'); document.write('</OBJECT>'); } else { document.write('<a href=\"' + url + '\" target=\"_blank\">'); document.write ('<img src="'+flash+'" width="'+width+'" height="'+height+'" border="0">'); document.write('<center><small>' + txt + '</small></center></a>'); } document.write('</center>'); // Fin </SCRIPT> </body> </html>
|
|
|
|
13/12/06, 02:57:48
|
#246 (permalink)
|
|
Moderador
Registrado: nov 2002
Ubicación: Torremolinos (Málaga)
Mensajes: 11.720
|
Re: FAQs JavaScript
P: Como obtener el código de una letra (ASCII)
R: Con el método charCodeAt().
El método se aplica a elementos del tipo String (texto) y el parámetro que recibe es la posición del elemento.
Ejemplo:
"A".charCodeAt(0) = 65; (A)
"Hola".charCodeAt(3) = 97 (a)
El método inverso sería fromCharCode(), donde los parámetros son los códigos de los caracteres que se obtendrán.
Ejemplo:
String.fromCharCode(104, 111, 108, 97) = "hola"

__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo
|
|
|
|
30/12/06, 16:38:27
|
#247 (permalink)
|
|
Moderador
Registrado: nov 2002
Ubicación: Torremolinos (Málaga)
Mensajes: 11.720
|
Re: FAQs JavaScript
P: Como borrar un input file
R: Por seguridad los campos file no son editables, pero se puede reemplazar por uno nuevo con el DOM
ver ejemplo:
Código:
<html>
<head>
<title>
prueba
</title>
<script type="text/javascript">
function valida(f) {
if (f.value.substr(f.value.length - 3).toUpperCase() == "JPG")
alert("Ok")
else {
alert("No");
siguiente = f.nextSibling;
fff = document.createElement("input");
fff.type = "file";
fff.name = f.name;
fff.onchange = f.onchange;
fff.value = "";
f.form.insertBefore(fff, siguiente);
f.form.removeChild(f);
}
}
</script>
</head>
<body >
<form action="" method="get" name="f">
<input type="file" name="jpg[0]" onChange="valida(this)"/>
<input type="file" name="jpg[1]" onChange="valida(this)"/>
<input type="file" name="jpg[2]" onChange="valida(this)"/>
<input type="file" name="jpg[3]" onChange="valida(this)"/>
</form>
</body>
</html>
Se ha tratado el tema en estos enlaces: ¿cómo pongo un campo file vacio desde javascript? y Vaciar un campo de formulario

__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo
|
|
|
|
03/01/07, 09:39:57
|
#248 (permalink)
|
Registrado: dic 2006
Mensajes: 2
|
Re: FAQs JavaScript
A las varias FAQ sobre agregar reloj, agrego esta de mi cosecha: En la barra de direcciones:
Cita:
javascript:(function(){document.body.onmousemove=n ew Function("var d = new Date();var reloj=d.toLocaleString();this.title=reloj")})();
O en
Cita:
<body onmousemove="var d = new Date();var reloj=d.toLocaleString();this.title=reloj" >
|
|
|
|
31/01/07, 17:00:54
|
#249 (permalink)
|
|
Colaborador
Registrado: oct 2003
Ubicación: self.location.href
Mensajes: 2.257
|
Re: FAQs JavaScript
P: ¿Cómo formateo un número con un separador de miles y uno de decimales? ¿Cómo vuelvo otra vez al formato original para operar?
R: He implementado unos cuantos métodos del objeto String para formatear un número con símbolos personalizados. format formatea y desFormat vuelve al estilo original.
Código:
<script language="Javascript">
String.prototype.reverse=function() { return this.split("").reverse().join(""); }
String.prototype.format=function(sepMil,sepDec) {
var partes=this.split("."); //dividimos parte entera de decimal
return partes[0].reverse().replace( /(\d{3})(?=\d)/g ,"$1"+sepMil).reverse() + (partes[1]?(sepDec + partes[1]):"");
}
String.prototype.desFormat=function(sepMil,sepDec) {
var reMil=new RegExp("\\"+sepMil,"g"); //para localizar los sepMil
var reDec=new RegExp("\\"+sepDec); //para localizar los sepDec
return this.replace(reMil,"").replace(reDec,".").replace(/\s/g,"");
}
var numeros=[123.41, 1234.001, 123456.00, 123, 12345, 12345678901];
</script>
<table border="1">
<script language="JavaScript">
for(var a in numeros) {
var n=numeros[a].toString();
var fn=n.format(".","'");
var dfn=fn.desFormat(".","'");
document.writeln("<tr><td>" + n + "</td><td>" + fn + "</td><td>" + dfn + "</td></tr>");
}
</script>
</table>
Recordad que son métodos para String, ¡habremos de convetir los números a String con toString()!
__________________
Inténtalo y búscalo siempre antes de preguntarlo
Última edición por derkenuke fecha: 31/01/07 a las 17:01:58.
Razón: La etiqueta [ p h p ] elimina las backslashes (\\)
|
|
|
|
31/01/07, 18:08:19
|
#250 (permalink)
|
|
Colaborador
Registrado: oct 2003
Ubicación: self.location.href
Mensajes: 2.257
|
Re: FAQs JavaScript
P: ¿Cómo formateo "al vuelo" mientras el usuario escribe en su caja de texto?
R:
Código:
<script language="Javascript">
String.prototype.reverse=function() { return this.split("").reverse().join(""); }
String.prototype.format=function(sepMil,sepDec) {
var partes=this.split("."); //dividimos parte entera de decimal
return partes[0].reverse().replace( /(\d{3})(?=\d)/g ,"$1"+sepMil).reverse() + (partes[1]?(sepDec + partes[1]):"");
}
String.prototype.desFormat=function(sepMil,sepDec) {
var reMil=new RegExp("\\"+sepMil,"g"); //para localizar los sepMil
var reDec=new RegExp("\\"+sepDec); //para localizar los sepDec
return this.replace(reMil,"").replace(reDec,".").replace(/\s/g,"");
}
//escogemos los separadores que queramos
var SEPMIL=".";
var SEPDEC="'";
document.write("Utiliza un "+SEPDEC+" como separador de decimales.<br/>");
</script>
<input type="text" onkeyup="handler(event,this)" />
<script language="javascript">
function handler(e,caja) {
//obtener la tecla pulsada
var code = (window.Event) ? e.which : e.keyCode;
var tecla = String.fromCharCode(code);
if(caja.value.lastIndexOf(SEPDEC)==caja.value.length-1) //se ha escrito SEPDEC, dejar empezar a escribir decimales
return;
else if( "1234567890".indexOf(tecla)>-1) { //se ha escrito un numero
caja.value=caja.value.desFormat(SEPMIL,SEPDEC).format(SEPMIL,SEPDEC);
return;
}
}
</script>
__________________
Inténtalo y búscalo siempre antes de preguntarlo
|
|
|
|
02/04/07, 04:55:56
|
#251 (permalink)
|
|
Colaborador
Registrado: may 2004
Mensajes: 1.094
|
251.-Selección en Textarea
P: Cómo seleccionar parte del contenido de un textarea sin usar el mouse?
R:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ejemplo</title>
<script>
function sel(inicio,fin){
input=document.getElementById('area');
if(typeof document.selection != 'undefined' && document.selection){
tex=input.value;
input.value='';
input.focus();
var str = document.selection.createRange();
input.value=tex;
str.move('character', inicio);
str.moveEnd("character", fin-inicio);
str.select();
}
else if(typeof input.selectionStart != 'undefined'){
input.setSelectionRange(inicio,fin);
input.focus();
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<textarea name="area" cols="60" rows="10" id="area">esta es una prueba</textarea>
<input type="button" name="Submit" value="seleccionar" onclick="sel(8,11)" />
</form>
</body>
</html>
Ejemplo probado en Safari, Explorer, Firefox y Ópera
|
|
|
|
02/05/07, 02:28:04
|
#252 (permalink)
|
|
Moderador
Registrado: nov 2002
Ubicación: Torremolinos (Málaga)
Mensajes: 11.720
|
Re: FAQs JavaScript
P: ¿Como recoger Datos por url?
R: Para datos simples se puede usar otro mensaje de estas FAQs: Recoger valores de un formulario, pero para recoger arrays se puede con el código de este mensaje: Recibiendo array por url
Pego a continuación una de las versiones (creo que la más corta):
Código:
function receptor() {
var entrada = new Object();
if (location.href.indexOf("?") == -1) return;
params = location.search.substr(1).split("&");
for (var i = 0, total = params.length; i < total; i ++) {
pareja = params[i].split("="); dato = unescape(pareja[1]);
switch (typeof(entrada[pareja[0]])) {
case "undefined": entrada[pareja[0]] = dato; break;
case "object": entrada[pareja[0]][entrada[pareja[0]].length] = dato; break;
case "string": temp = [entrada[pareja[0]], dato]; entrada[pareja[0]] = temp; break;
}
}
for (i in entrada) window[i] = entrada[i];
}
Saludos 
__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo
|
|
|
|
13/05/07, 07:15:09
|
#253 (permalink)
|
Registrado: nov 2004
Ubicación: Villa Ballester Bs-As|Ar
Mensajes: 1.610
|
Re: FAQs JavaScript
Pregunta: Como reproducir un sonido con eventos?
Respuesta:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Reproducir sonido - By Nicolás Pardo 2007</title>
<script>
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
/*Namespaces*/
var Media = document.Media || {};
// funciones para cookies
Media.PlaySound = {
MSIE: navigator.userAgent.indexOf("MSIE"),
NETS: navigator.userAgent.indexOf("Netscape"),
OPER: navigator.userAgent.indexOf("Opera"),
cookieName: "cookie_sound_active",
imgOn: "images/ico_on.gif",
imgOff: "images/ico_off.gif",
Sound: "_sonido.wav",
WriteCookie: function( name, value ){
var expdate=new Date();
expdate.setTime(expdate.getTime()+10*365*24*60*60*1000);
document.cookie = name + "=" + escape (value) + "; expires=" + expdate.toGMTString();
},
ReadCookie: function( name ){
var namearg = name + "=";
var nlen = namearg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + nlen;
if (document.cookie.substring(i, j) == namearg) {
var endpos = document.cookie.indexOf (";", j);
if (endpos == -1) endpos = document.cookie.length;
return unescape(document.cookie.substring(j, endpos));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
},
OnOffSound: function( img ){
newValue = Media.PlaySound.ReadCookie( Media.PlaySound.cookieName ) == 1 || Media.PlaySound.ReadCookie( Media.PlaySound.cookieName ) == null ? 0 : 1;
img.src = newValue == 1 ? Media.PlaySound.imgOn : Media.PlaySound.imgOff;
Media.PlaySound.WriteCookie( Media.PlaySound.cookieName, newValue );
},
SetMediaIE: function(){
if((Media.PlaySound.MSIE>-1) || (Media.PlaySoundOPER>-1)) {
document.write('<bgsound loop="0" name="MediaMyMediaObj" id="MediaMyMediaObj" >');
}
},
PlayNow: function(){
if( Media.PlaySound.ReadCookie( Media.PlaySound.cookieName ) == 1 || Media.PlaySound.ReadCookie( Media.PlaySound.cookieName ) == null ){
obj = MM_findObj("MediaMyMedia");
if((Media.PlaySound.MSIE>-1) || (Media.PlaySoundOPER>-1)) {
obj = MM_findObj("MediaMyMediaObj");
obj.src = Media.PlaySound.Sound;
} else {
obj = MM_findObj("MediaMyMediaDiv");
obj.innerHTML = '<embed src="'+Media.PlaySound.Sound+'" hidden="true" volume="200" loop="0" type="audio/midi" >';
}
}
}
}
Media.PlaySound.SetMediaIE();
</script>
</head>
<body>
<a href="#"><img src="images/ico_on.gif" onclick="Media.PlaySound.OnOffSound(this)" border="0" /></a>
<br />
<div name="MediaMyMediaDiv" id="MediaMyMediaDiv" style="margin:0; width:0; height:0;"></div>
<input type="button" value="dame" onclick="Media.PlaySound.PlayNow()" />
</body>
</html>
http://snipplr.com/view.php?codeview&id=2384
Testeado en IE y FF
__________________
Dicen comprender a la mente humana sabiendo que es ella quien les hace creer eso. [Nicolaspar]
Hoy: wysiwyg bbcode editor
|
|
|
|
13/05/07, 07:23:10
|
#254 (permalink)
|
Registrado: nov 2004
Ubicación: Villa Ballester Bs-As|Ar
Mensajes: 1.610
|
Re: FAQs JavaScript
Pregunta: Puedo eliminar la selección (encuadre) de los A?. Un ejemplo para explicar mejor el problema:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body>
<a href="asa.hh">Test link</a>
</body>
</html>
Guarden esto, y verán que al hacer TAB con el teclado sobre el documento el links se marcan. Muy molesto cuando tenemos botoneras con imagenes, o imagenes mapeadas, también aplica a anclas que quedan marcadas al darles clic.
Respuesta
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Un Focus by Nicolás Pardo</title>
<script>
function unFocusA() {
anclas=document.getElementsByTagName("a").length;
for (i=0;i<anclas;i++)
document.getElementsByTagName("a").item(i).onfocus=new Function("if(this.blur)this.blur()")
}</script>
</head>
<body onload="unFocusA()">
<a href="asa.hh">Test link</a>
</body>
</html>
__________________
Dicen comprender a la mente humana sabiendo que es ella quien les hace creer eso. [Nicolaspar]
Hoy: wysiwyg bbcode editor
|
|
|
|
13/05/07, 07:35:19
|
#255 (permalink)
|
Registrado: nov 2004
Ubicación: Villa Ballester Bs-As|Ar
Mensajes: 1.610
|
Re: FAQs JavaScript
Pregunta: Como avisarle al usuario que tiene un bloqueador de popup?
Respuesta:
Código:
function popup(url,ancho,alto,id,extras){
if(navigator.userAgent.indexOf("Mac")>0){ancho=parseInt(ancho)+15;alto=parseInt(alto)+15;}
var left = (screen.availWidth-ancho)/2;
var top = (screen.availHeight-alto)/2;
if(extras!=""){extras=","+extras;};
var ventana = window.open(url,id,'width='+ancho+',height='+alto+',left='+left+',top='+top+',screenX='+left+',screenY='+top+extras);
var bloqueado = "AVISO:\n\nPara ver este contenido es necesario que desactive\nel Bloqueo de Ventanas para este Sitio."
//var bloqueado = "WARNING:\n\nIn order to use this functionality, you need\nto deactivate Popup Blocking."
if(ventana==null || typeof(ventana.document)=="undefined"){ alert(bloqueado) }else{ return ventana; };
}
Notas:
1- Los bloqueadores generalmente trabajan sobre eventos que no son directos del usuario, ejemplo onload, con esto digo que no es necesario para eventos como ser onclick.
2- Hay bloqueadores que lo que hacen es abrir el popup y luego cerrarlo, para ellos esta función no aplica.
__________________
Dicen comprender a la mente humana sabiendo que es ella quien les hace creer eso. [Nicolaspar]
Hoy: wysiwyg bbcode editor
|
|
|
|
13/05/07, 07:41:24
|
#256 (permalink)
|
Registrado: nov 2004
Ubicación: Villa Ballester Bs-As|Ar
Mensajes: 1.610
|
Re: FAQs JavaScript
| |