Hallo Claudia
hier eine möglichkeit:
das ganze funktioniert wie folgt.
- eine fürs inhalts-frame gedachte seite prüft ob sie im richtigen frameset dargestellt wird.
- wenn nicht, ruft sie das richtige frameset auf und übergibt die adresse zu sich selbst in der url als variable.
- im frameset wird geprüft ob die besagte variable vorhanden ist/übergeben wurde, und wenn ja wird das inhalts-frame entsprechen neu geladen.
<!-- hier der code fuer eine inhaltsseite -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"
http://www.w3.org/...tml4/strict.dtd"> <html><head><title>Inhalts Seite</title>
<script language="JavaScript" type="text/javascript">
<!--
//var frameSetUrl = '
http://www.meinehomepage.ch/frameset.html'; var frameSetUrl = 'frameset.html';
var selfLocation = new String(self.document.location);
var topLocation = new String(top.document.location);
if (topLocation.indexOf(frameSetUrl) == -1) {
//alert('wrong frameset: '+ topLocation);
top.document.location = frameSetUrl +'?page='+ selfLocation;
}
//-->
</script>
</head><body>ich bin die inhaltsseite</body></html>
<!-- hier der code fuer das frameset -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"
http://www.w3.org/...l4/frameset.dtd"> <html><head><title>Frameset</title>
<script language="JavaScript" type="text/javascript">
<!--
//--------------------------------------------------
// initialization
// wenn geladen rufe funktion initialize auf
onload = initialize;
function initialize() {
// extrahiere die in der url übergebene variable 'page'
var query = location.search.substring(1);
var args = getArgs(query);
var contentLocation = new String(window.frames['contentFrame'].document.location);
// wenn variable 'page' vorhanden ist
if (typeof args.page != 'undefined') {
// und die url auf welche 'page' zeigt noch nicht geladen ist
if (contentLocation != args.page) {
// dann lade die seite ins inhalts-frame
// (ich habe hier location.replace() verwendet damits keinen eintrag in der Hystory gibt)
window.frames['contentFrame'].document.location.replace(args.page);
}
}
}
//--------------------------------------------------
//--------------------------------------------------
// function getArgs
//--------------------------------------------------
// extracts variables out of location string
// and returns them as a objects properties
//--------------------------------------------------
function getArgs(str) {
var args = new Object();
var pairs = str.split(",");
for (var i=0; i<pairs.length; i++) {
var pos = pairs
.indexOf("=");
if (pos == -1) continue;
var argname = pairs.substring(0,pos);
var value = pairs.substring(pos+1);
args[argname] = unescape(value);
}
return args;
}
//--------------------------------------------------
//-->
</script>
</head>
<frameset rows="30%,70%">
<frame src="about:blank" name="topFrame" />
<frameset cols="20%,80%">
<frame src="about:blank" name="navFrame" />
<frame src="seite.html" name="contentFrame" />
</frameset>
</frameset>
<noframes><body>Your browser does not support FRAMES.</body></noframes></html>
alternativ könnte man das frameset mit document.write dynamisch erzeugen was einen overhead bei obigem beispiel elimieren würde.
aber so ist es suchmaschienen freundlicher.
hope this helps
gruss
Steven