[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Scroll Window to Anchor

Posted on 2006-05-08
6
Medium Priority
?
530 Views
Last Modified: 2008-01-09
Im trying to move the webbrowser display down to a created anchor position rather than having the user scroll down to this important area.  I've already tried using <a name="#a"> and then JS to do a Location.href/hash.  it worked but when the user goes to hit the browser back button, they must hit it twice to actually move back.  Annoying.  I cant modify the origianl URL which does not contain a hash.  Im suspecting JS needs to be involved.  I've tried using scrollIntoView but i get no effect (nothing happens).

Im using Windows 2000 Pro and IE6 but would like the code to run under IE5+ and Firefox and Windows 2000 and Windows XP.

Thanks
0
Comment
Question by:aniston
  • 4
  • 2
6 Comments
 
LVL 11

Expert Comment

by:mvan01
ID: 16630974
Can you do a simple href?

<a href="#glossary">Scroll to Glossary</a>

I suppose [Back] doesn't scroll from the tag location back to the link location?

Another way is, if the user must hit [Back] [Back], with your method as you said, then can you tack on:

history.go(-1);

to your location.href javascript tag?  That would preload with one [Back].

Peace and joy.  mvan
0
 

Author Comment

by:aniston
ID: 16637871
Hmm, I would ideally like to make the extra history item invisible to client.  How can i acheive that in code?

Is there an event for when th euser clicks back for me to trigger an additional go(-1)?
0
 
LVL 11

Expert Comment

by:mvan01
ID: 16638646
Sure, it should be invisible to the user.  You said you're using "JS to do a Location.href/hash" and that's when you need the additional go(-1).  So you can do both in the same onClick event, something like this:

onClick="location.href='#a';history.go(-1);"

Maybe give that a try?

Peace and joy.  mvan
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Expert Comment

by:mvan01
ID: 16638666
I meant to say, of course, use whatever construct you said had worked for you before, and tack on the history.go(-1) to it as I showed above.

Peace and joy.  mvan
0
 

Author Comment

by:aniston
ID: 16641597
Darn, sounded great but not working.  The page is a Rainbow portal asp.net page.  The user clicked a dynamic hyperlink on one page ands was taken to this new page.  This new page is of course showing the content at the top of the display.  We want it to move the view down to about half way down as soon the page appears without user intervention.  After the user finishes reading the contents they are likely to click the webbrowser's back button (not our on-page back link).  When they click the browerser's back button it move the display back to top, then click again finally it moves to prev screen.  Very annoying.  Thats waht we need to resolve.

Thanks
0
 
LVL 11

Accepted Solution

by:
mvan01 earned 80 total points
ID: 16643487
Ahhh ... look into the destination page -- someone else's, I understand, so you cannot add an anchor -- view source of that page, look around in the content, and see if there is something, a named <span> or named <div> and try to use that as an anchor.  It has worked for me before.

In someone else's source file, you find e.g.:

<div name="myLoc" id="myLoc">

Then you call it:

<a href="http://some.domain.com/dir/dir/sourceFile.html#myLoc">

Please give it a try, with whatever you find in the destination source file.

Peace and joy.  mvan
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question