Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/05/2009, 05:42
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 2 meses
Puntos: 574
Respuesta: Control de clicks en Iframe

Archivo principal

Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function iframeclick(obj) {
obj.contentWindow .document.onmousedown = function() {
alert("Funciona " + obj.src);
}
} 
</script>
</script>
</head>

<body>
Primer<br>
<iframe src="iframes.htm" width='300' height='250' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' id="theiframe" name="theiframe" onload="iframeclick(this)"></iframe>
</body>
</html> 
Dos alternativas para el iframes.htm (archivo que se carga en el primer iframe)

Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function iframeclick(obj) {
obj.contentWindow .document.onmousedown = function() {
alert("Funciona " + obj.src);
}
} 
</script>
</head>

<body>
Segon<br>
<iframe src="capas.htm" width='300' height='250' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' id="theiframe" name="theiframe" onload="iframeclick(this)"></iframe>
</body>
</html> 
Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Segon<br>
<iframe src="xxx_pagina" width='300' height='250' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' id="theiframe" name="theiframe" onload="parent.iframeclick(this)"></iframe>
</body>
</html> 
Te sirve?

Es decir o repites la funcion o usas "parent." para referirte a la funcion del primer archivo....

Quim