Jumping in a frame using Javascript

  • Thread starter compassSoftware
  • Start date
C

compassSoftware

Hi,

I have two horizontal frames, one on top of the other.

The top frame is an image map of a street with property boundary's on
it.

The bottom frame is a table with each row of the table holds details
about a perticular property from the image map above.

The user clicks on the image map in the top frame and the corresponding
row in the table is highlighted in the bottom frame.

The table is very long and the rows continue below the visable canvas.

What i need is a way to jump to the row when it is highlighted so that
it displays no matter where in the table it is located.

Is it possible to jump in a frame or page using Javascript?
 
C

compassSoftware

Here is the script I am using (just encase it helps someone get an idea
of what I mean).
"passdata" is the row id being passed in from the top frame. The row id
is used to find and highlight the corresponding row. What I really need
to do is to be able to use the row id to jump to a particular area of
the frame.

<script type="text/javascript">
<!--
var passdata = 1;
var oldpassdata = 1;

function Start() {
if(oldpassdata != passdata)
ShowPass();

id1 = setTimeout("Start();", 100); // check value every .1 sec.
}

function ShowPass() {
highlightrow(passdata);
oldpassdata = passdata;
}

function highlightrow(n){
clearallrows()
document.getElementById(n).style.backgroundColor='#FFAABB';
}

function clearallrows(){
if (oldpassdata ==1)
oldpassdata = passdata;

document.getElementById(oldpassdata).style.backgroundColor='#FFFFFF';

}
// -->
</script>
 
C

c.anandkumar

Use anchors. For each row, have an anchor close to it with a unique
name. You can have something like rown. So for each row, have an anchor
text near to it with name/id = rown. You can then jump to that row by
setting the location property of the bottom frame to the anchor name.
sthg like this in the highlightrow (n) function :
eval ("bottomFrameName.location='row" + n + "'");

Thanks

Anand.
 
C

compassSoftware

I used the bottomFrame2.locaton='row' + n; and when i do I get
bottomFrame2 is undefined.


I then tried to place the document object before bottomFrame2 and I get

Document.bottomFrame2 is null or not an object error.

Any ideas?
 
C

compassSoftware

I used document.location='row' + n and I get "The page cannot be found"
error message in the bottom frame.
 
E

Evertjan.

wrote on 08 mrt 2005 in comp.lang.javascript:
I used the bottomFrame2.locaton='row' + n; and when i do I get
bottomFrame2 is undefined.

[please ALWAYS quote. Usenet is not email, and others want to read too]

bottomFrame2.locaton='row' + n;

locaton ?????????????
 
C

compassSoftware


I misspelled while typing in usernet, "location" is spelled properly in
my code.

Here is the code if it helps.
function highlightrow(n){
clearallrows()
document.getElementById(n).style.backgroundColor='#FFAABB';
bottomFrame2.location='row' + n;
}

Sorry but I am unfamilar with quoting. I use google (I thought everyone
did) and I can see all related post.

If my
hack from above works I will try to use it more.
 
C

compassSoftware

I am using eval and I have put the # in. However I am still getting
bottomFrame2 is undefined.

So I replaced bottomFrame2 with document as the scrip is in the head of
the page that I want to jump around in.
eg
function highlightrow(n){
clearallrows()
document.getElementById(n).style.backgroundColor='#FFAABB';
eval ("document.location='#row" + n + "'");
}

I don't recieve any errors now however I'm not jumping either.

I have check the code and the anchor tag is there. It is in a table
outside of each row. eg
<a name=row140></a><tr id=140><td>140</td></tr>
 
C

compassSoftware

Ok progress, It works so long as the anchors are outside of the table.

Problem is the table is generated pragmatically using asp.net. It is
built with a dataset populated with the property information from my
database. I loop through the dataset and create a new row in my table
for each for in the dataset.

I will try to create each row as a single table and put the anchor
after the table (what a hack!) There has to be a better solution.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Tue, 8
Mar 2005 09:20:23, seen in Evertjan.
wrote on 08 mrt 2005 in comp.lang.javascript:
[please ALWAYS quote. Usenet is not email, and others want to read too]

I see no point in telling Googlers what to do without telling them how
to do it; be constructive, not just critical.

Keith Thompson wrote :-
If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

Does new Google now allow indentation?

What's "mrt" ?!?
 
C

c.anandkumar

I guess the script that moves the content in the bottomframe must be
called from the parent page which has this frame object. And the anchor
text now should be the relative path of the "tables" page followed by
the anchor.
 
C

compassSoftware

I guess the script that moves the content in the bottomframe must be
called from the parent page which has this frame object. And the anchor
text now should be the relative path of the "tables" page followed by
the anchor.

The script actually is called with the onload event in the body. There
is a timer that compares two variables. One variable is changed by the
sibling frame. If the two variables are not equal then the row is
highlighted.

So it is all happening in the one page but you are right. I need to
reference the table. If the anchor is in the table it can't be found.

How can I refernce the table in my script?

Here is the code where I reference the anchor:
eval ("document.location='#row" + n + "'");

PS. Thanks for the tip on quoting! Pardon my lack of Usenet netiquette.

Everybody should try google groups beta. (Emphasis on beta) It is a
much improved product. I used Usenet a few years ago when I first found
the net. I would never go back to using it now.
 
E

Evertjan.

Dr John Stockton wrote on 08 mrt 2005 in comp.lang.javascript:
JRS: In article <[email protected]>, dated Tue, 8
Mar 2005 09:20:23, seen in Evertjan.
wrote on 08 mrt 2005 in comp.lang.javascript:
[please ALWAYS quote. Usenet is not email, and others want to read too]

I see no point in telling Googlers what to do without telling them how
to do it; be constructive, not just critical.

I do see a point, John:

I am being critical, so you can be constructive.

;-}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top