javascript scroll to anchor

Here is the issues im running into....

I have a page that loads a modal which loads a remote page that has a bunch of text in it.

I load the modal via jquery.

I need to have javascript or whatever scroll to a anchor on the page. right now im storing the anchor in a cookie. So lets say I have 3 anchors, they are named 1, 2, 3 in the cookie when someone clicks on link 2 it stores "2" into the cookie when the modal loads I need i to look a the cookie and scroll to that number.

One of the issues is it cannot reload the page so a window.location... will not work because that actually closes down the modal.

Any solutions that anyone can think of???

Thanks
LVL 4
aumudinAsked:
Who is Participating?
 
hernst42Connect With a Mentor Commented:
does it work if you use:
window.location.hash = '#anchorname';

It shouldn't reload the page, but jump to the anchor.
0
 
aumudinAuthor Commented:
That did the trick I figured out what I did wrong when I tried that(first thing I tried) I didnt have the # just had the name of the anchor.... Thank you for helping me hernst!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.