Foros del Web » Programando para Internet » Javascript »

eliminar contenido de iframe

Estas en el tema de eliminar contenido de iframe en el foro de Javascript en Foros del Web. hola.. estoy llamando a una funcion que hace un window.frames[0].document.write('ALGO'); el problema es que cada vez que la llamo me anexa el ALGO a lo ...
  #1 (permalink)  
Antiguo 22/07/2005, 08:55
Avatar de dieguicho  
Fecha de Ingreso: noviembre-2001
Ubicación: Buenos Aires
Mensajes: 1.190
Antigüedad: 22 años, 5 meses
Puntos: 1
eliminar contenido de iframe

hola.. estoy llamando a una funcion
que hace un
window.frames[0].document.write('ALGO');

el problema es que cada vez que la llamo me anexa el ALGO a lo existente
como puedo borrar todo lo que tiene?
no existe un document.clear() por ej?

gratzie!
__________________
On error no hago nada porque deje de fumar...
  #2 (permalink)  
Antiguo 22/07/2005, 09:02
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
y si al iframe el contenido lo ensierras a un span y luego a ese span le aplicas innerHTML = "" ???
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
  #3 (permalink)  
Antiguo 22/07/2005, 09:16
Avatar de dieguicho  
Fecha de Ingreso: noviembre-2001
Ubicación: Buenos Aires
Mensajes: 1.190
Antigüedad: 22 años, 5 meses
Puntos: 1
lo hice con el body que es igual a lo que propones, pero no me lo limpia... lo sigue anexando
__________________
On error no hago nada porque deje de fumar...
  #4 (permalink)  
Antiguo 22/07/2005, 09:22
Avatar de dieguicho  
Fecha de Ingreso: noviembre-2001
Ubicación: Buenos Aires
Mensajes: 1.190
Antigüedad: 22 años, 5 meses
Puntos: 1
ademas el problema es quew al iframe lo genero desde javascript, osea que inicialmente esta vacio
__________________
On error no hago nada porque deje de fumar...
  #5 (permalink)  
Antiguo 22/07/2005, 09:31
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
pon el codigo para ver
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
  #6 (permalink)  
Antiguo 22/07/2005, 09:37
Avatar de dieguicho  
Fecha de Ingreso: noviembre-2001
Ubicación: Buenos Aires
Mensajes: 1.190
Antigüedad: 22 años, 5 meses
Puntos: 1
esta es la funcion....

Código:
function mostrarMenu(cual,que){
	var menu = "";
	menu = menu + "<body style=\"border:0px;background-color: #EEEEEE\">\n";	
	menu = menu + "<link href=\"http://www.localhost/css/main.css\" rel=\"stylesheet\" type=\"text/css\">\n";
	menu = menu + "<table border=\"0\" cellpadding=\"2\" cellspacing=\"1\" class=\"menu\" id=\"menu\">\n";
	menu = menu +  que;
	menu = menu + "</table>\n";
	menu = menu + "</body>\n";

	window.frames(cual).document.write(menu);
	document.getElementById(cual).className='visible';
}
y aca esta la tabla .... con el boton y el iframe
Código:
<table border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td><button onmouseover="Javascript:mostrarMenu('iframe100','<tr><td>hola</td></tr>')">mostrar 
      menu sobre un combo-box</button></td>
  </tr>
  <tr> 
    <td><iframe id="iframe100" class="oculto" onmouseout="Javascript:if(checkMouseLeave(this,event)){ocultarMenu(this);}"></iframe></td>
  </tr>
</table>
estilos...

Código:
<style type="text/css">
<!--
iframe {
	position: absolute;
	z-index: 100;
}

iframe.oculto {
	display:none;
	visibility:hidden;
}

iframe.visible {
	display:block;
	visibility:visible;
}
-->
</style>
perdon por la choclera de codigo..
__________________
On error no hago nada porque deje de fumar...
  #7 (permalink)  
Antiguo 22/07/2005, 09:41
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
y la funcion checkMouseLeave??
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
  #8 (permalink)  
Antiguo 22/07/2005, 09:46
Avatar de dieguicho  
Fecha de Ingreso: noviembre-2001
Ubicación: Buenos Aires
Mensajes: 1.190
Antigüedad: 22 años, 5 meses
Puntos: 1
aqui te la mando.. es para saber si el puntero esta fuera del area y ahi llama a una funcion que oculta el iframe

Código:
function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}
Código:
function ocultarMenu(objeto){
	objeto.className='oculto'
}
__________________
On error no hago nada porque deje de fumar...
  #9 (permalink)  
Antiguo 22/07/2005, 10:06
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
bueno, en realidad no se si lo que quieres es limpiar el contenido del iframe...bueno, con table no se puede limpiar, por eso te decia que utilizaras span...

chquea esto:

Código HTML:
<script language="javascript">
 function mostrarMenu(cual,que){
  var menu = "";
  menu = menu + "<body style=\"border:0px;background-color: #EEEEEE\">\n"; 
  menu = menu + "<link href=\"http://www.localhost/css/main.css\" rel=\"stylesheet\" type=\"text/css\">\n";
  menu = menu + "<span id=\"menu\">" + que + "<span>\n";
  menu = menu + "</body>\n";
  
  window.frames(0).document.write(menu);
  document.getElementById(cual).className='visible';
 }
 
 function limpiar(obj) {
  var d = document.all;
  obj = eval("d." + obj);
  window.frames(0).document.getElementById("menu").innerText = "";
 }
</script>
<body>
<input type="button" name="Button" value="limpiar" onClick="limpiar('iframe100')">
<table border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
	<td><button onmouseover="javascript:mostrarMenu('iframe100','<tr><td>hola</td></tr>')">mostrar 
	  menu sobre un combo-box</button></td>
  </tr>
  <tr> 
	<td><iframe id="iframe100" class="oculto"></iframe></td>
  </tr>
</table> 
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
  #10 (permalink)  
Antiguo 22/07/2005, 10:12
Avatar de dieguicho  
Fecha de Ingreso: noviembre-2001
Ubicación: Buenos Aires
Mensajes: 1.190
Antigüedad: 22 años, 5 meses
Puntos: 1
y que vacie directamente el iframe esa funcion no se podra?
fijate que el iframe inicialmente esta vacio.. y le escribo el contenido con esas funciones
por eso no puedo hacer getElementById.. porque no existe ningun elemento aun
__________________
On error no hago nada porque deje de fumar...
  #11 (permalink)  
Antiguo 22/07/2005, 10:15
Avatar de Saruman  
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 21 años
Puntos: 5
si, pero una vez que lo llenes... pasandole el mouse y que cargue algun texto entonces presionaas limpiar... eso era lo que pedias no? que limpiara el iframe....
me avias
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
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 07:50.