logamweb
13-sep-2005, 18:30
********************
Hola con todos , el presente es un recopilado de preguntas relacioandas con javascript , algunas fueron tomadas de internet y algunas (muy pocas) , fueron creados por su amigo Logamweb
, espero , se unan ala encuesta y me permitan saver su opinion sobre estas F.A.Q , si tiene dudas sobre java script , por favor creen un nuevo post y pongan hay sus preguntas , y gustosamente seran respondidas , no llenemos este post con preguntas sin sentido
por favor , lo que se busca es crear una especia de diccionario con preguntas y respuestas , muchas gracias , espero me hayan comprendido , no olviden votar ok [-o<
********************
.- Navegar con un menú desplegable (select)
<select name="select" onChange="location.href=this.value">
<option value="paginauno.html">Pagina 1</option>
<option value="paginados.html">Pagina 1</option>
<option value="paginatres.html">Pagina 1</option>
</select>
.- Deshabilitar selección de texto
<script language="JavaScript">
function disableselect(e)
{
return false
}
function reEnable()
{
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar)
{
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>
P . ¿Cómo crear botón de "guardar como..."?
<HTML>
<HEAD>
<script language="javascript">
function guardarcomo()
{
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(4, 0);
WebBrowser1.outerHTML = "";
}
</script>
</HEAD>
<BODY>
Oprime el botón para guardar esta página...<BR>
<input type="submit" value=" Guardar " onClick=guardarcomo() name="miboton">
</BODY>
</HTML>
Dar estilos CSS para los links
P: ¿como doy estilos CSS a los hipervinculos?
CAMBIA COLOR AL PASAR EL RATÓN POR LO ALTO DEL ENLACE...
<a href="" onmouseover="this.style.color='red';" onmouseout="this.style.color='';">This HREF turns red on hover.</a>
----------------------------------------------------------------
HIPERVINCULOS O LINKS DE COLOR VERDE.
<a href="" style="color:green;">This HREF is green.</a>
-----------------------------------------------------------------------
HIPERVINCULO SIN RAYA POR DEBAJO
<a href="" style="text-decoration: none;">This HREF has no underline.</a>
---------------------------------------------------------------------
LINEA DE ESPACIO DE UN HIPERVINCULO
<a href="" style="line-spacing:150%;">These HREFs are spaced 150% of normal.</a>
<a href="" style="line-spacing:150%;">These HREFs are spaced 150% of normal.</a>
-----------------------------------------------------------------------
ESPACIO ENTRE LOS CARACTERES DE UN HIPERVINCULO
<a href="" style="letter-spacing:5px;">This HREF has 5 pixels between letters</a>
-----------------------------------------------------------------------
COLOR DE FONDO EN LOS LINKS
<a href="" style="background:ffffcc;">This HREF has a yellow background.</a>
-----------------------------------------------------------------------
P ¿Como detecto flash player?
<script language="JavaScript"><!--
function MM_checkPlugin(plgIn, theURL, altURL, autoGo) {
var ok=false; document.MM_returnValue = false;
with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
ok=(plugins && plugins[plgIn]);
} else if (appVersion.indexOf('3.1')==-1) {
if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
else ok=autoGo; }
if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_checkPlugin('Shockwave Flash','index.html','http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=L atinAmerica&P5_Language=Spanish',true);return document.MM_returnValue">
P¿Como detecto shockwave player?
<!--
function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
var ok=false; document.MM_returnValue = false;
with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
ok=(plugins && plugins[plgIn]);
} else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
else ok=autoGo; }
if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_checkPlugin('Shockwave for Director','index.html','http://www.macromedia.com/shockwave/download/download.cgi?Lang=LatinAmerica&P5_Language=Spanish ',true);return document.MM_returnValue">
P: ¿Cómo puedo hacer para que cada vez que se abra una página muestre un banner aleatorio, ya sea un archivo swf o un archivo gif?
<html>
<head>
<title>Selección de Banners Aleatorios</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
width="468"; //Anchura del banner
height="60"; //Altura del banner
banners= new Array();
banners[0]="banner1.gif";
banners[1]="banner2.gif";
banners[2]="banner3.swf";
banners[3]="banner4.gif";
banners[4]="banner5.swf";
totalbanners = banners.length;
var ahora = new Date()
var segundos = ahora.getSeconds()
var ad = segundos % totalbanners;
seleccionado=banners[ad];
localizador=seleccionado.lastIndexOf('.');
localizador2=localizador+4
extension=seleccionado.substring(localizador+1,loc alizador2);
archivo=seleccionado.substring(0,localizador);
document.write("<center>");
if (extension=="swf"){
flash=seleccionado;
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('<img src='+seleccionado+' width='+width+' height='+height+'>');
document.write('</center>');}
// Fin
</SCRIPT>
<!-- RESTO DE PÁGINA-->
</body>
</html>
P: ¿Como se puede manipular mediante JavaScript los botones "Atrás", "Adelante" y "Recargar" del navegador?
<html>
<head>
</head>
<body>
<b>Manipular una páginia individual o frame actual</b><br>
<a href="javascript:history.reload()">Recargar esta página o frame</a><br>
<a href="javascript:history.back()">Ir a página (o frame) anterior</a><br>
<a href="javascript:history.forward()">Ir a página (o frame) siguiente</a><br><br>
<b>Manipular un frame vecino</b><br>
<a href="javascript:parent.frames[2].history.reload()">Recargar un frame vecino</a><br>
<a href="javascript:parent.frames[2].history.back()">Ir a frame vecino anterior</a><br>
<a href="javascript:parent.frames[2].history.forward()">Ir a frame vecino siguiente</a><br><br>
<b>Manipular un frame vecino usando su nombre</b><br>
<a href="javascript:parent.nombreDelFrame.history.reload()">Recargar un frame vecino (por nombre)</a><br>
<a href="javascript:parent.nombreDelFrame.history.back()">Ir a frame vecino anterior (por nombre)</a><br>
<a href="javascript:parent.nombreDelFrame.history.forward() ">Ir a frame vecino siguiente (por nombre)</a><br><br>
</body>
</html>
Hola con todos , el presente es un recopilado de preguntas relacioandas con javascript , algunas fueron tomadas de internet y algunas (muy pocas) , fueron creados por su amigo Logamweb
, espero , se unan ala encuesta y me permitan saver su opinion sobre estas F.A.Q , si tiene dudas sobre java script , por favor creen un nuevo post y pongan hay sus preguntas , y gustosamente seran respondidas , no llenemos este post con preguntas sin sentido
por favor , lo que se busca es crear una especia de diccionario con preguntas y respuestas , muchas gracias , espero me hayan comprendido , no olviden votar ok [-o<
********************
.- Navegar con un menú desplegable (select)
<select name="select" onChange="location.href=this.value">
<option value="paginauno.html">Pagina 1</option>
<option value="paginados.html">Pagina 1</option>
<option value="paginatres.html">Pagina 1</option>
</select>
.- Deshabilitar selección de texto
<script language="JavaScript">
function disableselect(e)
{
return false
}
function reEnable()
{
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar)
{
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>
P . ¿Cómo crear botón de "guardar como..."?
<HTML>
<HEAD>
<script language="javascript">
function guardarcomo()
{
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(4, 0);
WebBrowser1.outerHTML = "";
}
</script>
</HEAD>
<BODY>
Oprime el botón para guardar esta página...<BR>
<input type="submit" value=" Guardar " onClick=guardarcomo() name="miboton">
</BODY>
</HTML>
Dar estilos CSS para los links
P: ¿como doy estilos CSS a los hipervinculos?
CAMBIA COLOR AL PASAR EL RATÓN POR LO ALTO DEL ENLACE...
<a href="" onmouseover="this.style.color='red';" onmouseout="this.style.color='';">This HREF turns red on hover.</a>
----------------------------------------------------------------
HIPERVINCULOS O LINKS DE COLOR VERDE.
<a href="" style="color:green;">This HREF is green.</a>
-----------------------------------------------------------------------
HIPERVINCULO SIN RAYA POR DEBAJO
<a href="" style="text-decoration: none;">This HREF has no underline.</a>
---------------------------------------------------------------------
LINEA DE ESPACIO DE UN HIPERVINCULO
<a href="" style="line-spacing:150%;">These HREFs are spaced 150% of normal.</a>
<a href="" style="line-spacing:150%;">These HREFs are spaced 150% of normal.</a>
-----------------------------------------------------------------------
ESPACIO ENTRE LOS CARACTERES DE UN HIPERVINCULO
<a href="" style="letter-spacing:5px;">This HREF has 5 pixels between letters</a>
-----------------------------------------------------------------------
COLOR DE FONDO EN LOS LINKS
<a href="" style="background:ffffcc;">This HREF has a yellow background.</a>
-----------------------------------------------------------------------
P ¿Como detecto flash player?
<script language="JavaScript"><!--
function MM_checkPlugin(plgIn, theURL, altURL, autoGo) {
var ok=false; document.MM_returnValue = false;
with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
ok=(plugins && plugins[plgIn]);
} else if (appVersion.indexOf('3.1')==-1) {
if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
else ok=autoGo; }
if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_checkPlugin('Shockwave Flash','index.html','http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=L atinAmerica&P5_Language=Spanish',true);return document.MM_returnValue">
P¿Como detecto shockwave player?
<!--
function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
var ok=false; document.MM_returnValue = false;
with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
ok=(plugins && plugins[plgIn]);
} else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
else ok=autoGo; }
if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_checkPlugin('Shockwave for Director','index.html','http://www.macromedia.com/shockwave/download/download.cgi?Lang=LatinAmerica&P5_Language=Spanish ',true);return document.MM_returnValue">
P: ¿Cómo puedo hacer para que cada vez que se abra una página muestre un banner aleatorio, ya sea un archivo swf o un archivo gif?
<html>
<head>
<title>Selección de Banners Aleatorios</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
width="468"; //Anchura del banner
height="60"; //Altura del banner
banners= new Array();
banners[0]="banner1.gif";
banners[1]="banner2.gif";
banners[2]="banner3.swf";
banners[3]="banner4.gif";
banners[4]="banner5.swf";
totalbanners = banners.length;
var ahora = new Date()
var segundos = ahora.getSeconds()
var ad = segundos % totalbanners;
seleccionado=banners[ad];
localizador=seleccionado.lastIndexOf('.');
localizador2=localizador+4
extension=seleccionado.substring(localizador+1,loc alizador2);
archivo=seleccionado.substring(0,localizador);
document.write("<center>");
if (extension=="swf"){
flash=seleccionado;
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('<img src='+seleccionado+' width='+width+' height='+height+'>');
document.write('</center>');}
// Fin
</SCRIPT>
<!-- RESTO DE PÁGINA-->
</body>
</html>
P: ¿Como se puede manipular mediante JavaScript los botones "Atrás", "Adelante" y "Recargar" del navegador?
<html>
<head>
</head>
<body>
<b>Manipular una páginia individual o frame actual</b><br>
<a href="javascript:history.reload()">Recargar esta página o frame</a><br>
<a href="javascript:history.back()">Ir a página (o frame) anterior</a><br>
<a href="javascript:history.forward()">Ir a página (o frame) siguiente</a><br><br>
<b>Manipular un frame vecino</b><br>
<a href="javascript:parent.frames[2].history.reload()">Recargar un frame vecino</a><br>
<a href="javascript:parent.frames[2].history.back()">Ir a frame vecino anterior</a><br>
<a href="javascript:parent.frames[2].history.forward()">Ir a frame vecino siguiente</a><br><br>
<b>Manipular un frame vecino usando su nombre</b><br>
<a href="javascript:parent.nombreDelFrame.history.reload()">Recargar un frame vecino (por nombre)</a><br>
<a href="javascript:parent.nombreDelFrame.history.back()">Ir a frame vecino anterior (por nombre)</a><br>
<a href="javascript:parent.nombreDelFrame.history.forward() ">Ir a frame vecino siguiente (por nombre)</a><br><br>
</body>
</html>