Por que o IE8 não manipula eventos onload de iframe?
Código de amostra:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
function on_iframe_load() {
document.getElementById('iframe_a').onload = function() {
alert('Thanks for the visit!');
};
}
</script>
</head>
<body>
<iframe name="iframe_a" id="iframe_a"></iframe>
<a href="http://www.example.com/" target="iframe_a" onclick="on_iframe_load();">Go!</a>
</body>
</html>
Ele funciona em todos os principais navegadores sem problemas, mas o IE8 (e provavelmente as versões anteriores) não o entendem.
Atualizar: Acabei de chegar a uma solução, mas não tenho certeza se está certo codificação. Por favor revise:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
var clicked = false;
function activate() {
clicked = true;
}
function pop() {
if (clicked) {
alert('Thanks for the visit!');
};
}
</script>
</head>
<body>
<iframe name="iframe_a" onload="pop();"></iframe>
<a href="http://www.example.com/" target="iframe_a" onclick="activate();">Go!</a>
</body>
</html>