[redirection d'URL] incompatibilité de IE
Bonjour,
J'ai une page web avec frame.
Je voudrais que si une personne ouvre la fenêtre en dehors des frames, elle soit redirigée à l'intérieur.
J'ai donc la structure suivante:
lib
+--- test.js
perso
+-- test1.html
+-- test.html
test.js est un fichier javascript contenant la fonction de redirection:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| function redirect(page) {
alert(page);
if (parent.frames.length < 1) {
document.write("AH PEUR!");
document.write(
"<frameset rows='20%,*' border=0>"+
"<frameset cols='25%,*' border=0>"+
"<frame name='pub' src='./test1.html' marginheight=1 marginwidth=1 noresize scrolling='no'>"+
"<frame name='banner' src='./test1.html' marginheight=1 marginwidth=1 noresize scrolling='no'>"+
"</frameset>"+
"<frameset cols='25%,*' border=0>"+
"<frame name='menu' src='./test1.html' marginheight=1 marginwidth=1 noresize scrolling='auto'>"+
"<frame name='princip' src='./"+page+"' marginwidth=1 marginheight=1 noresize scrolling='auto'>"+
"</frameset>"+
"<noframes>"+
"<body>"+
"Please Use a Browser that support Frame!<br>"+
"for example: free browser: <a href='http://www.mozilla.org/products/firefox/'><b>Firefox</b></a><br>"+
"</body>"+
"</noframes>"+
"</frameset>"
);
}
} |
le fichier test1.html est un fichier banal (entête, marge, ...)
le fichier test.html doit être redirigé à l'intérieur de la frame princip:
il appelle la fonction de la façon suivante:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-language" content="fr" lang="fr">
<meta name="generator" content="HTML-Kit">
<script language="JavaScript" src="../lib/test.js" type="text/javascript"></script>
<SCRIPT LANGUAGE="JavaScript">
redirect("test.html");
</script>
</head>
<body>
BOUH!
</body>
</html> |
Ce code marche parfaitement avec firefox... Mais pas du tout avec IE?
alors que document.write est compatible avec IE
et parent.frames.length est aussi compatible IE.
Képassa?
Avez vous une idée pour rendre mon code compatible avec IE afin que test.html soit redirigé dans la frame "princip"?
Merci pour votre aide.