Foros del Web » Programando para Internet » Javascript »

Ayuda: corrigiendo script

Estas en el tema de Ayuda: corrigiendo script en el foro de Javascript en Foros del Web. Hola: Encontre un script para poner un post-it en una web, pero tenia bastantes errores, ya corregi algunos, pero todavia no funciona correctamente. apenas estoy ...
  #1 (permalink)  
Antiguo 14/06/2008, 11:08
 
Fecha de Ingreso: junio-2008
Mensajes: 5
Antigüedad: 15 años, 11 meses
Puntos: 0
Ayuda: corrigiendo script

Hola: Encontre un script para poner un post-it en una web, pero tenia bastantes errores, ya corregi algunos, pero todavia no funciona correctamente.

apenas estoy aprendiendo a programar, entonces todavia no puedo lograr que el link de cerrar lo haga, ni tampoco puedo hacer que con el btn. derecho se pueda arrastrar el post-it por la pantalla y ponerlo en cualquier lugar.

Expertos, necesito ayuda por favor!!!

el codigo es el siguiente:

<html><head>

<style>
<!--
#postit{
position:absolute;
width:250;
padding:5px;
background-color:yellow;
border:1px solid black;
visibility:visible;
z-index:500;
cursor:hand;
height: 199px;
}
-->
</style>

</head>


<body>
Con el boton derecho del raton puedes arrastrar el POSTIT donde quieras para que no moleste.

<div id= "postit" style= "left:255px; top:48px">
<div align= "right"><b><a href="javascript:closeit()"><font face="Arial" size="1">[CERRAR]</font></a></b></div>

<!-- INSERTA EL CONTENIDO AQUÍ -->

<b>AVISO</b><br>
<p>
<font size="2" face="Arial"><a href="http://www.programacion.com" target="_BLANK"><font face="Verdana" size="1">Entra en Programacion en castellano</font><br>
</a><br>Esto es un solo ejemplo. Un aviso para que la gente que entra en la web lo vea, y que una vez visto lo pueda cerrar sin problemas.
<p><strong>Aqui dentro puedes utilizar</strong> <font color="#FF0000">todos los codigos html que quieras, </font>

<!-- FIN DEL CONTENIDO -->
</div>

<script>
var once_per_browser=0
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ns4)
crossobj=document.layers.postit
else if (ie4||ns6)
crossobj=ns6? document.getElementById("postit") : document.all.postit


function closeit(){
if (ie4||ns6)
crossobj.style.visibility= "hidden"
else if (ns4)
crossobj.visibility= "hide"
}

function get_cookie4(Name) {
var search = Name + "= "
var returnvalue = " ";
if (document.cookie4.length > 0) {
offset = document.cookie4.indexOf(search)
if (offset != -1) {
// if cookie4 exists
offset += search.length
// set index of beginning of value
end = document.cookie4.indexOf( "; ", offset);
// set index of end of cookie4 value
if (end == -1)
end = document.cookie4.length;
returnvalue=unescape(document.cookie4.substring(of fset, end))
}
}
return returnvalue;
}

function showornot(){
if (get_cookie4 ("postdisplay")==' '){
showit()
document.cookie4= "postdisplay=yes"
}

function showit(){
if (ie4||ns6)
crossobj.style.visibility= "visible"
else if (ns4)
crossobj.visibility= "show"
}

if (once_per_browser)
showornot()
else
showit()

</script>

<script language= "JavaScript1.2">

//función arrastrar y soltar para ie4+ y NS6////
function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx
crossobj.style.top=tempy+e.clientY-offsety
return false
}
}

function initializedrag(e){
if (ie4&&event.srcElement.id== "postit"||ns6&&e.target.id== "postit"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")

</script>

</body></html>
  #2 (permalink)  
Antiguo 14/06/2008, 14:33
 
Fecha de Ingreso: octubre-2003
Ubicación: Cerca de una wifi o 3G
Mensajes: 328
Antigüedad: 20 años, 6 meses
Puntos: 4
Respuesta: Ayuda: corrigiendo script

Código HTML:
<!-- POSTIT -->
<html><head>
   
<style>
<!--
#postit{
position:absolute;
width:250;
padding:5px;
background-color:yellow;
border:1px solid black;
visibility:hidden;
z-index:500;
cursor:hand;
}
-->
</style>
 
</head>
 
    
<body>
Con el botón derecho del ratón puedes arrastrar el POSTIT donde quieras para que no moleste.
 
<div id="postit" style="left:150px;top:150px">
<div align="right"><b><a href="javascript:closeit()"><font face="Arial" size="1">[CERRAR]</font></a></b></div>
 
<!-- INSERTA EL CONTENIDO AQUÍ -->
 
<b>AVISO</b><br>
<p><font size="2" face="Arial"><a href="http://www.programacion.com" target="_BLANK"><font face="Verdana" size="1">Entra en Programación en castellano</font><br>
</a><br>Esto es un solo ejemplo. Un aviso para que la gente que entra en la web lo vea, y que una vez visto lo pueda cerrar sin problemas.<p><strong>Aqui dentro puedes utilizar</strong> <font color="#FF0000">todos los codigos html que quieras, </font><font size="3">para confeccionar el aviso o noticia.</font></p>
 
<!-- FIN DEL CONTENIDO -->
 
</div>
 
<script>
 
var once_per_browser=0;
 
///No modifiques lo que sigue///
 
var ns4=document.layers;
var ie4=document.all;
var ns6=document.getElementById&&!document.all;
var offsetxx;
var offsetyy;
if (ns4)
crossobj=document.layers.postit;
else if (ie4||ns6)
crossobj=ns6? document.getElementById("postit") : document.all.postit;
 

function closeit(){
if (ie4||ns6)
crossobj.style.visibility="hidden";
else if (ns4)
crossobj.visibility="hide";
}
 
function get_cookie4(Name) {
  var search = Name + "=";
  var returnvalue = "";
  if (document.cookie4.length > 0) {
    offset = document.cookie4.indexOf(search);
    if (offset != -1) { // if cookie4 exists
      offset += search.length;
      // set index of beginning of value
      end = document.cookie4.indexOf(";", offset);
      // set index of end of cookie4 value
      if (end == -1)
         end = document.cookie4.length;
      returnvalue=unescape(document.cookie4.substring(offset, end));
      }
   }
  return returnvalue;
}
 
function showornot(){
if (get_cookie4('postdisplay')==''){
showit();
document.cookie4="postdisplay=yes";
}
}
 
function showit(){
if (ie4||ns6)
crossobj.style.visibility="visible";
else if (ns4)
crossobj.visibility="show";
}
 
if (once_per_browser)
showornot();
else
showit();
 
</script>
 
<script language="JavaScript1.2">
 
//función arrastrar y soltar para ie4+ y NS6////
function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetxx;
crossobj.style.top=tempy+event.clientY-offsetyy;
return false;
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetxx;
crossobj.style.top=tempy+e.clientY-offsetyy;
return false;
}
}
 
function initializedrag(e){
if (ie4&&event.srcElement.id=="postit"||ns6&&e.target.id=="postit"){
offsetxx=ie4? window.event.clientX : e.clientX;
offsetyy=ie4? window.event.clientY : e.clientY;
 
tempx=parseInt(crossobj.style.left);
tempy=parseInt(crossobj.style.top);
 
dragapproved=true;
document.onmousemove=drag_drop;
}
}
document.onmousedown=initializedrag;
document.onmouseup=new Function("dragapproved=false");
 
</script>
 
</body></html> 
Lo probe en ie 7

En teoria cualquier codigo antiguo deberia funcionar pero es mejor que ocupes algo que ya esta funcionando, lo arregle de pura suerte, pero tenia varios problemas.

Como consejo si dice ie4 o ie5 mejor sigue buscando, este script debe ser como del 2002 o mas antiguo

Edite el post por que lo corregí para FF tambien,

Una nota mas ocupe el ultraedit para corregirlo y tuve que poner offsetyy y offsetxx por que no habia caso de colocar offsety ya que me dejaba la ultima letra en mayuscula, me desagrada cuando un programa no te deja escribir algo y te lo "corrige" quizas no tenia tantos problema y ese fue mi error.

Saludos

Última edición por Remsankar; 14/06/2008 a las 14:40
  #3 (permalink)  
Antiguo 16/06/2008, 07:58
 
Fecha de Ingreso: junio-2008
Mensajes: 5
Antigüedad: 15 años, 11 meses
Puntos: 0
Respuesta: Ayuda: corrigiendo script

ok. quedo super................mil gracias!!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:53.