Link to home
Start Free TrialLog in
Avatar of chrome2000
chrome2000

asked on

anchors, links, frames

hi everyone:

i am using frames on couple of pages of my website. now, if i try to link to a section (anchor) of one of the pages that is part of the frameset, it always goes to the top of the page. this is what i mean:

my files look like this:

frameset1.htm
untitledFrame-1.htm
untitledFrame-2.htm
untitledFrame-3.htm

as you can see, frameset1.htm controls the positioning and so on of the untitledFrame-1.htm, untitledFrame-2.htm, and untitledFrame-3.htm pages. these are three sections one next to the other one. i am interested in creating an anchor in one of the pages, let say on untitledFrame-2.htm. now i need to link to that section by somehow calling href=frameset1.htm (to keep all the sections together) but at the same time to the anchor on untitledFrame-2.htm

is that clear ???

thanks.
Avatar of knightEknight
knightEknight
Flag of United States of America image

actually, that isn't to clear :)  but if I can guess this -- you want a single click to simultaneously change the position of all three framed pages, correct?

<A href="#" onclick="top.frame1.location='#anchor1';top.frame2.location='#anchor2';top.frame3.location='#anchor3';return false;"> click </a>
and in each of the three pages you have anchors like this:

  content
  <A name="anchor1"></a>
  content
hmm, you may have to specify the entire page name -- i'm not sure:

    ...  top.frame1.location='untitledFrame-1.htm#anchor1';  ...
also, the code above assumes your frames are named "frame1","frame2","frame3"
oh!  now I re-read your Q and I think i got it ...

You can do this in your link to the frameset page:

<A href="frameset1.htm?anchor2" > open frameset </a>

then in the frameset page, do this:

<FRAMESET>
  <FRAME name="frame1" src="untitledFrame-1.htm" > 
  <FRAME name="frame2" >
  <FRAME name="frame3" src="untitledFrame-3.htm" >
</FRAMSET>

<SCRIPT language="javascript">
   top.frames["frame2"].location = "untitledFrame-2.htm#" + location.search.substring(1);
</SCRIPT>
... and in untitledFrame-2.htm you have an anchor:

  content
  <A name="anchor2"></a>
  content

Avatar of chrome2000
chrome2000

ASKER

hold on my man, i have to digest this slowly
ok ... this worked for me ... here is the frameset page:

<HTML>

<SCRIPT language="javascript">
 function onLoadHandler()
 {
   var f2url = "untitledFrame-2.htm#" + location.search.substring(1);
   alert(f2url);
   top.frames["frame2"].location = f2url;
 }
</SCRIPT>

<FRAMESET rows="80,80,*" onload="onLoadHandler();">
  <FRAME name="frame1" src="untitledFrame-1.htm" > 
  <FRAME name="frame2" >
  <FRAME name="frame3" src="untitledFrame-3.htm" >
</FRAMSET>

</HTML>
remove the alert, ofcourse.


Here is the link I used to open the above frameset page:

  <A href="frameset1.htm?anchor2" > open frameset </a>



and here is the frame2 page:

 <html>
 <body>
 <p> content </p>
 <p> content </p>
 <p> content </p>

  <A name="anchor2"></a>

 <p> content </p>
 <p> content </p>
 <p> content </p>
 </body>
 </html>
hi knightEknight:

that did not work

here is how my code looks on the frameset page i hope you can copy it and paste it so you can see it more clear :)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

top.frames["centreFrame"].location = "UntitledFrame-15.htm#" + location.search.substring(1);


MM_reloadPage(true);
//-->
</script>
</head>
<frameset cols="153,*" frameborder="NO" border="0" framespacing="0">
  <frame src="UntitledFrame-2.htm" name="leftFrame" scrolling="NO" noresize>
  <frameset rows="*" cols="1,*" framespacing="0" frameborder="NO" border="0">
    <frame src="UntitledFrame-3.htm" name="leftFrame1" scrolling="NO" noresize>
    <frameset rows="*" cols="750,110" framespacing="0" frameborder="NO" border="0">
      <frameset rows="*" cols="*,1" framespacing="0" frameborder="NO" border="0">
        <frameset rows="54,*" cols="*" framespacing="0" frameborder="NO" border="0">
          <frame src="UntitledFrame-6.htm" name="topFrame" scrolling="NO" noresize >
          <frameset rows="1,*" cols="*" framespacing="0" frameborder="NO" border="0">
            <frame src="UntitledFrame-7.htm" name="topFrame1" scrolling="NO" noresize >
            <frameset rows="10,*" cols="*" framespacing="0" frameborder="NO" border="0">
              <frame src="UntitledFrame-8.htm" name="topFrame2" scrolling="NO" noresize >
              <frameset rows="1,*" cols="*" framespacing="0" frameborder="NO" border="0">
                <frame src="UntitledFrame-9.htm" name="topFrame3" scrolling="NO" noresize >
                <frameset rows="21,*" cols="*" framespacing="0" frameborder="NO" border="0">
                  <frame src="UntitledFrame-10.htm" name="topFrame4" scrolling="NO" noresize >
                  <frameset rows="1,*" cols="*" framespacing="0" frameborder="NO" border="0">
                    <frame src="UntitledFrame-11.htm" name="topFrame5" scrolling="NO" noresize >
                    <frameset rows="10,*" cols="*" framespacing="0" frameborder="NO" border="0">
                      <frame src="UntitledFrame-12.htm" name="topFrame6" scrolling="NO" noresize >
                      <frameset rows="1,*" cols="*" framespacing="0" frameborder="NO" border="0">
                        <frame src="UntitledFrame-13.htm" name="topFrame7" scrolling="NO" noresize >
                        <frameset rows="10,*" cols="*" framespacing="0" frameborder="NO" border="0">
                          <frame src="UntitledFrame-14.htm" name="topFrame8" scrolling="NO" noresize >
                          <frame name="centreFrame" >
                        </frameset>
                      </frameset>
                    </frameset>
                  </frameset>
                </frameset>
              </frameset>
            </frameset>
          </frameset>
        </frameset>
        <frame src="UntitledFrame-5.htm" name="rightFrame1" scrolling="NO" noresize>
      </frameset>
      <frame src="UntitledFrame-4.htm" name="rightFrame" scrolling="NO" noresize>
    </frameset>
  </frameset>
</frameset>
<noframes><body>

</body></noframes>
</html>

here is the section where i link the picture to the section that i want to load:

<tr>
      <td><a href="applications/applicationss.html?pharmaceuticals" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image78','','../../images/graphics/applications/general_dark.png',1)"><img src="../../images/graphics/applications/general_light.png" name="Image78" width="250" height="20" border="0"></a></td>
   
 </tr>

here is my anchor in the page

<td width="35%" bordercolor="#666666" bgcolor="#D6D6C0" > <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><a name="pharmaceuticals"></a>Pharmaceuticals</strong></font></div></td>

sorry but i tried different things and i get this error

Not Found
The requested object does not exist on this server. The link you followed is either outdated, inaccurate, or the server has been instructed not to let you have it. Please inform the site administrator of the referring page./

thank you for your help

rene
let my try what you wrote in your last couple of comments
hi knightEknight:

still does not work. i think that the problem is on the script:

function onLoadHandler()
{
   var f2url = "UntitledFrame-15.htm" ;
   alert(f2url);
   top.frames["centreFrame"].location = f2url;
}

it shows the correct link on the alert(f2url) but when it tries to load the frame on the frameset it gives me this error:

Not Found
The requested object does not exist on this server. The link you followed is either outdated, inaccurate, or the server has been instructed not to let you have it. Please inform the site administrator of the referring page.f

i think that the problem is here:

top.frames["centreFrame"].location = f2url;

by the way both the frameset and each of the frames (pages), are in the same folder  ????

any ideas ??

thanks
you will have to adjust for the number and level (heirarchy) of frames that you have.
that is what i thought but if i just write it has it is, it means that i am at root ??

this is how my files and folders look

index.html       (0)
pages folder    (0)
-->main pages folder  (1)
---->applications folder (2)
------>frameset.htm         (3)
------>untitledframe.htm   (3)
------>untitledframe2.htm   (3)
------>untitledframe3.htm   (3)

even better:

-what does this do ??

top.frames["centreFrame"].location = f2url;

-i would rather understand what each thing do in this line

-should something like this do the trick ???

var f2url = "../../../UntitledFrame-15.htm" ;


thank you very much
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi knightEknight:

i see what you mean, the only problem is that i have never play with this kind of code

top.leftFrame.leftFrame1.topFrame.topFrame1.topFrame2 ... topFrameN.centreFrame.location = f2url;

can you tell me how it works ?

thank you very much