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

window scrolling problem 2

Status
Not open for further replies.

foxphpbomb

Programmer
Apr 10, 2007
29
US
I have a function that is invoked on an onclick event linked to some text, that sets the diplay property of a row just below the link to block from none.

The problem is that the page is verticlaly very long and when the javascript is invoked, I get scrolled all the way to the top, and then have to scroll all the way down to get to the point where I was before and the newly visible row.

I need to add something to this function that anchors me to the point in the page where I invoked the function.
 
This kind of thing happens when you use an anchor:
Code:
<a href="#" onclick="someFunc();">click me</a>
The javascript function will be run, and then the href will be visited (the # part) -- causing the page to reload at the id specified (# in this case relates to the top of the page). You can prevent this many ways...
Code:
<a href="#" onclick="someFunc();[!]return false;[/!]">click me</a>
Or...
Code:
<a href="javascript://" onclick="someFunc();">click me</a>
Or...
Code:
<a href="javascript:someFunc();">click me</a>
The first method (using return false) is the preferred method [smile]

I hope this is of value to your problem. If not... we might need to see the code where you do this.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top