Jump to content

Go to top when link is clicked


kvnirvana

Recommended Posts

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><TITLE>SearchCare</TITLE><script language="JavaScript"><!--function calcHeight(){//find the height of the internal pagevar the_height=document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;//change the height of the iframedocument.getElementById('the_iframe').height=the_height;}//--></script></HEAD><BODY ><DIV style="position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:1" align="left"><TABLE width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><img src="se.jpg" width="1259" height="170" /></TABLE></DIV><DIV style="position:absolute;center:0px;top:143px;width:100%;height:100%;z-index:1" align="left"><TABLE  width="100%" height="100%" border="0" cellpadding="0" cellspacing="1"><TR><TD align="left" valign="top" width="122" height="100%"><B><A href="fore.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Fore</B></FONT></TD><TD align="left" valign="top" width="122" height="100%"><B><A href="sg.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Sg</A></B></FONT></TD><TD align="left" valign="top" width="160" height="100%"><B><A href="ben.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000"> ben</B></FONT></TD><TD align="left" valign="top" width="122" height="100%"><B><A href="org.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Org</B></FONT></TD><TD align="left" valign="top" width="95" height="100%"><B><A href="/wordpress/" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Blog</B></FONT></TD><TD align="left" valign="top" width="135" height="100%"><B><A href="kt.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000"> er</B></FONT></TD><TD align="left" valign="top" width="112" height="100%"><B><A href="kon.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Kon</B></FONT></TD></TR></TABLE></DIV><DIV style="position:absolute;center:0px;top:165px;width:100%;height:100%;z-index:1" align="left"><TABLE width="100%" height="100%" border="0" cellpadding="0" cellspacing="1"><TR><TD align="left" valign="top" width="100%" height="40"><FONT style="font-size:16px" color="#000000" face="Arial"><B><hr></B></FONT></TD></TR></TABLE></DIV><iframe width="100%" id="the_iframe" name="kasp" onLoad="calcHeight();" style="position:absolute;center:1px;top:175px;z-index:2" src="fore.php" scrolling="NO" frameborder="0" height="1"> iframe capable browser is required to view this web site.</iframe></BODY></HTML>

 

 

How can I make it so when a link is clicked in the iframe window it jumps to the top of not just the Iframe, but the whole page? Tried to put an anchor in this part

 

<BODY ><DIV style="position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:1" align="left"><TABLE width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><img src="se.jpg" width="1259" height="170" /></TABLE></DIV>

 

but it doesn’t work. Is there a way to do this with javascript?

Link to comment
https://forums.phpfreaks.com/topic/214907-go-to-top-when-link-is-clicked/
Share on other sites

Create an anchor within the body of your parent frame:

 

 

<a name="top"></a>

 

 

Then reference that within the child frame, specifying the target "_top" frame:

 

 

<a href="#top" target="_top">Top of parent frame</a>

 

 

-------

 

Sorry no, that won't work. Give me a minute..

Ok, so I did it like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>SearchCare</TITLE>
<script language="JavaScript">function parentTop(){    parent.window.location.hash = '#top';}</script>
<script language="JavaScript">
<!--
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindow.
document.body.scrollHeight;

//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
//-->
</script>

</HEAD>

<BODY >
<DIV style="position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:1" align="left">
<TABLE width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<img src="se.jpg" width="1259" height="170" />

</TABLE></DIV>


<DIV style="position:absolute;center:0px;top:143px;width:100%;height:100%;z-index:1" align="left">
<TABLE  width="100%" height="100%" border="0" cellpadding="0" cellspacing="1">
<TR>
<TD align="left" valign="top" width="122" height="100%"><B><A href="fore.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Fore</B></FONT></TD>
<TD align="left" valign="top" width="122" height="100%"><B><A href="sg.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Sg</A></B></FONT></TD>
<TD align="left" valign="top" width="160" height="100%"><B><A href="ben.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000"> ben</B></FONT></TD>
<TD align="left" valign="top" width="122" height="100%"><B><A href="org.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Org</B></FONT></TD>

<TD align="left" valign="top" width="95" height="100%"><B><A href="/wordpress/" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Blog</B></FONT></TD>
<TD align="left" valign="top" width="135" height="100%"><B><A href="kt.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000"> er</B></FONT></TD>
<TD align="left" valign="top" width="112" height="100%"><B><A href="kon.php" target="kasp"><font style="font-size:18px" face="Arial" color="#000000">Kon</B></FONT></TD>
</TR>
</TABLE></DIV>
<DIV style="position:absolute;center:0px;top:165px;width:100%;height:100%;z-index:1" align="left"><TABLE width="100%" height="100%" border="0" cellpadding="0" cellspacing="1"><TR><TD align="left" valign="top" width="100%" height="40"><FONT style="font-size:16px" color="#000000" face="Arial"><B><hr></B></FONT></TD></TR></TABLE></DIV>

<iframe width="100%" id="the_iframe" name="kasp" onLoad="calcHeight();" style="position:absolute;center:1px;top:175px;z-index:2" src="fore.php" scrolling="NO" frameborder="0" height="1"> iframe capable browser is required to view this web site.</iframe>

</BODY>
</HTML>

 

And then made an anchor like this

<a href="#top" >Top of parent frame</a>

on a page called ww.php which opens in th Iframe, but it still doesn't take me to the top, only to the top of the Iframe

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.