Hello M rosi,
You want a link in an iframed page to go to an anchor in another iframed page, where the iframed pages are not contained in the same main page. I googled around, no success.
So I made a script of my own (see below). The important thing to note is that you cannot go from an iframed page (contained in a main page MP1) to an anchor in another iframed page (contained in another main page MP2) unless you have the 2 iframed pages encompassed by one and the same main page (other than MP1 and MP2). Let's call that main page 'index.html'. Also, the iframed pages should be dynamically generated. Let's call them 'parented_1.html' and parented_2.html, respectively.
With this in mind, try the following:
index.html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>
<style type="text/css">
iframe {position: absolute; left:10%; top: 10%; width:89%; height: 89%; border:1px solid black; background: white}
body {background: #dedede}
</style>
<script type="text/javascript">
contentURL = parent.document.URL.substring(parent.document.URL.indexOf('?')+1, parent.document.URL.length);
if (top.location == contentURL)top.location.href='index.html?parented_1.html';
onload=function()
{
var OBJ = document.createElement("iframe");
OBJ.setAttribute("src", contentURL);
OBJ.setAttribute("name", contentURL);
OBJ.setAttribute("id", "content");
OBJ.setAttribute("frameborder", "0");
document.body.appendChild(OBJ);
}
</script>
</head>
<body><div>
<a href="index.html?parented_1.html">parented_1.html</a><br>
<a href="index.html?parented_2.html">parented_2.html</a>
</div></body>
</html>
parented_1.html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>
<script type="text/javascript">
function orph(){
if (top.location == self.location)
top.location.href="index.html?" + document.URL
}
window.onload=orph;
</script>
</head>
<body><div>
This is parented_1.html, iframed in index.html<br>
<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>
<a name="mylink"></a>WE LAND HERE COMING FROM A LINK IN parented_2.html<br>
<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br><br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br><br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>bla<br>
</div>
</body>
</html>
parented_2.html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>
<script type="text/javascript">
//This keeps the iframed pages from showing without their main page
function orph(){
if (top.location == self.location)
top.location.href="index.html?" + document.URL
}
window.onload=orph;
</script>
</head>
<body><div>
This is parented_2.html, iframed in index.html<br>
<a href="javascript: void(0)" onmousedown="top.location.href='index.html?parented_1.html#mylink'" >go to an anchor in parented_1.html, also contained in index.html</a>
</div></body>
</html>
Arie Molendijk.
Bookmarks