Hey, here is my problem. I have this script that loads one page into a DIV on another page. The main page loads the secondary page into an iframe and then loads that into a <DIV> in the body of the main page. This means that the secondary page can be changed without reloading the entire page. My problem is that I need the main page to scroll down to a <A Name="meet"> tag on new page to be loaded into the <DIV> when a link is clicked. Right now it scrolls down only if the link is clicked for a second time. The problem is that it will only see the <name> tag after the second page has been loaded. If you look at the code you will understand better. Here it is: (also avalible in html format at
Main page (main.htm)
Here is the first page to be loaded (loaded.htm)
here is the second page to be loaded (about.htm)
Thanks in advance for any light you can shed on this subject.
Main page (main.htm)
Code:
<html>
<head>
<title>main</title>
<script language="JavaScript">
// functions to load page into DIV
var nn4 = (document.layers);
var nn6 = (document.getElementById && !document.all);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
function loadPage(id,nestref,url) {
if (nn4) {
var lyr = (nestref)? eval('document.'+nestref+'.document.'+id) : document.layers[id]
lyr.load(url,lyr.clip.width)
}
else if(ie4) parent.contentFRM.location = url;
else if(ie5 || nn6) document.getElementById('contentFRM').src = url;
}
function showPage(id) {
if (ie4) {
document.all[id].innerHTML = parent.contentFRM.document.body.innerHTML;
}
else if(nn6 || ie5) {
document.getElementById(id).innerHTML = window.frames['contentFRM'].document.getElementById('theBody').innerHTML;
}
}
</script>
</head>
<body onLoad="javascript:loadPage('contentLayer',null,'loaded.htm')">
<A HREF="#meet" onClick="javascript:loadPage('contentLayer',null,'about.htm')">link to about</a>
<!--about.htm is the new file to be loaded -->
<!--I need the script to scroll down to the "meet" name tag in about.htm. If you click the link twice it works but I need it to do it the first time-->
<iframe name="contentFRM" id="contentFRM" width="0" height="0" frameborder="0">
</iframe>
<div id="contentLayer"></div> <!-- this is the div into which the second file is loaded -->
</body>
</html>
Here is the first page to be loaded (loaded.htm)
Code:
<HTML>
<head>
</head>
<body id="theBody" onload="parent.showPage('contentLayer')">
loaded.htm file. This is the first file loaded into the DIV.
</body>
</HTML>
here is the second page to be loaded (about.htm)
Code:
<HTML>
<HEAD>
<TITLE>about</TITLE>
</HEAD>
<BODY id="theBody" onload="parent.showPage('contentLayer')">
This page is loaded when the link is clicked.
If you click the link again it will scroll down.
<BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR>
<A NAME="meet">This is where it should scroll to.</a>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
</BODY>
</HTML>
Thanks in advance for any light you can shed on this subject.