By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,969 Members | 2,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,969 IT Pros & Developers. It's quick & easy.

Jumping in a frame using Javascript

P: n/a
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?

Jul 23 '05 #1
Share this Question
Share on Google+
17 Replies


P: n/a
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.backgro undColor='#FFFFFF';

}
// -->
</script>

Jul 23 '05 #2

P: n/a
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.

Jul 23 '05 #3

P: n/a
Thank you for that! That sounds like just what I need.

Jul 23 '05 #4

P: n/a
c.**********@gmail.com wrote on 07 mrt 2005 in comp.lang.javascript:
eval ("bottomFrameName.location='row" + n + "'");


why the evil eval?

bottomFrameName.location='row' + n

wouldn't that work?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #5

P: n/a
Yeah. Thanks

Jul 23 '05 #6

P: n/a
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?

Jul 23 '05 #7

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

Jul 23 '05 #8

P: n/a
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 ?????????????

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #9

P: n/a
locaton
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 [quote] hack from above works I will try to use it more.

Jul 23 '05 #10

P: n/a
you should use #rown. not just rown. using eval works for me fine.

Jul 23 '05 #11

P: n/a
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>

Jul 23 '05 #12

P: n/a
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.

Jul 23 '05 #13

P: n/a
wrote on 08 mrt 2005 in comp.lang.javascript:
Sorry but I am unfamilar with quoting. I use google (I thought everyone
did) and I can see all related post.


Usenet is over 20 years old, even much older than the web.
No, Google is only used for usenet by a minority.
Most people use a dedicated news-reader.

Read up on Usenet and Usenet netiquette.

<http://www.google.com/search?q=Usenet+netiquette+quoting>
20,600 hits

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #14

P: n/a
JRS: In article <Xn********************@194.109.133.29>, dated Tue, 8
Mar 2005 09:20:23, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.net> posted :
wrote on 08 mrt 2005 in comp.lang.javascript:
I
[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" ?!?

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 23 '05 #15

P: n/a
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.

Jul 23 '05 #16

P: n/a
c.**********@gmail.com wrote:
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.

Jul 23 '05 #17

P: n/a
Dr John Stockton wrote on 08 mrt 2005 in comp.lang.javascript:
JRS: In article <Xn********************@194.109.133.29>, dated Tue, 8
Mar 2005 09:20:23, seen in news:comp.lang.javascript, Evertjan.
<ex**************@interxnl.net> posted :
wrote on 08 mrt 2005 in comp.lang.javascript:
I

[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.

;-}

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.