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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to force a table row to scroll into view 1

Status
Not open for further replies.

RexHeadlong

Programmer
Apr 10, 2002
35
US
Hey, all.
The short version: Is there a Netscape 6+ equivalent for the IE scrollIntoView() function?

The long version: I have to support both NN6+ and IE5+. I have a table with lots of rows in it. The table is in a <DIV style=&quot;overflow:auto&quot;>. I want to force a given row to be scrolled to the top of the page when I load the page. The following code works great in IE:


<HTML>
<HEAD></HEAD>
<BODY onLoad=&quot;document.all.row101.scrollIntoView(true)&quot;>

... a bunch of content here ...

<DIV style=&quot;overflow:auto; width=100%; height:400px; margin:0px&quot;>
<TABLE width=&quot;100%&quot;>
<THEAD><TR><TH>my table header</TH></TR></THEAD>
<TBODY>
<TR id=&quot;row001&quot;><TD>row 1 text</TD></TR>

... lots more rows here ...

<TR id=&quot;row101&quot;><TD>row 101 text</TD></TR>

... more rows here ...

</TBODY>
</TABLE>
</DIV>
</BODY>


So, is there a NN equivalent to the scrollIntoView function, or is there an alternate technique to force the scroll?

Thanks for any help!
 
An alternate would be anchor names...


<HTML>
<HEAD></HEAD>
<BODY onLoad=&quot;document.location='#row101'&quot;>

... a bunch of content here ...

<DIV style=&quot;overflow:auto; width=100%; height:400px; margin:0px&quot;>????? Not sure you want both
<TABLE width=&quot;100%&quot;>
<THEAD><TR><TH>my table header</TH></TR></THEAD>
<TBODY>
<TR id=&quot;row001&quot;><TD>row 1 text</TD></TR>

... lots more rows here ...

<TR id=&quot;row101&quot;><TD><a name=&quot;row101&quot;>row 101 text</a></TD></TR>

... more rows here ...

</TBODY>
</TABLE>
</DIV>
</BODY>
Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Mike,
Thanks for the reply. I'm trying it, but so far I'm getting an 'invalid character' error in the document.location=#row101 part. Note I only get this error in IE. But regardless, it still don't work in NN.

In reading some references, it looks like document.location has been deprecated in favor of document.URL. And, document.URL is a read-only property. So, I am trying to use window.location.href instead, but I'm still getting the 'invalid character' error.

I'll keep messing with it.
 
Needs quotes around it. I tested in IE5.5 before I posted first time.

document.location=&quot;#row101&quot;

<BODY onLoad=&quot;document.location='#row101'&quot;>

<TR id=&quot;row101&quot;><TD><a name=&quot;row101&quot;>row 101 text</a></TD></TR>
Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
I think I figured I need quotes just as you were posting (duh!).

So, I'm not getting errors any more, but Netscape still seems to ignore the document.location='#row101' directive.

I'll keep trying
 
Ok, got it.
document.location='#row101' works,
So does window.location.href='#row101'

My problem was that I still had the IE-specific code in there and it was messing up Netscape

Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top