Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Target problem 1

Status
Not open for further replies.

lumy

Programmer
Jul 25, 2001
3
CA
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=&quot;meet&quot;> 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)
Code:
<html>
<head>
<title>main</title>
<script language=&quot;JavaScript&quot;> 
// 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=&quot;javascript:loadPage('contentLayer',null,'loaded.htm')&quot;>
<A HREF=&quot;#meet&quot; onClick=&quot;javascript:loadPage('contentLayer',null,'about.htm')&quot;>link to about</a> 
<!--about.htm is the new file to be loaded -->
<!--I need the script to scroll down to the  &quot;meet&quot;  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=&quot;contentFRM&quot; id=&quot;contentFRM&quot; width=&quot;0&quot; height=&quot;0&quot; frameborder=&quot;0&quot;>
</iframe>
<div id=&quot;contentLayer&quot;></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=&quot;theBody&quot; onload=&quot;parent.showPage('contentLayer')&quot;>
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=&quot;theBody&quot; onload=&quot;parent.showPage('contentLayer')&quot;>

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=&quot;meet&quot;>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.
 
hie the problem is that u have 2 call &quot;top.location.href='#meet'&quot; when ur frame wuld finish loading..
i puted this string in about.htm like this:
<BODY id=&quot;theBody&quot; onload=&quot;parent.showPage('contentLayer'); top.location.href='#meet'&quot;>
& looks like it works, but i get &quot;object doesnt support this property or method&quot; error on this string.. weird, i cant get what is the error.. but at least it works..

play around it & u'll get rid off the error..
regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top