pkAirman
Posts: 2
Joined: Tue Feb 24, 2015 8:56 pm

scroll position lost (returns top of page) upon hs Close

http://www.btel.net/hs001.html

Scroll down and click on "More Content 2" then Close. How do I maintain scroll position or keep it from returning to top of page upon window close?
MisterNeutron
Posts: 440
Joined: Sun Aug 18, 2013 11:20 am

Re: scroll position lost (returns top of page) upon hs Close

I think you'll need to be a little devious. The href="#" always takes you back to the top of the page. Replace this:

Code: Select all

<a href="#" onclick="hs.close(this)">Close</a>
With this:

Code: Select all

<div class="closer" onclick="hs.close(this)">Close</div>
Of course, you'll want to do some styling on that div to make "Close" look like a normal link, and to provide a suitable cursor:

Code: Select all

<style>
.closer {
	width: 35px;
	margin: 0 auto;
	text-decoration: underline;
	color: blue;
	cursor: pointer;
}
</style>
Better, of course, to put an "X" icon in the box to do the closing, so you don't need to tinker with the size of the text, and so on - just float the "X" to the top right corner, for example. The Highslide graphics include a close.png you can use.
MisterNeutron
Posts: 440
Joined: Sun Aug 18, 2013 11:20 am

Re: scroll position lost (returns top of page) upon hs Close

If you wanted to do an "X", change the padding-top on highslide-body to 30px. Then:

Code: Select all

<div class="closer" onclick="hs.close(this)"><img src="/hstest/highslide/graphics/close.png" alt="close x" title="Close"></div>
And styling:

Code: Select all

<style>
.closer {
	float: right;
	cursor: pointer;
	line-height: 0px;
}
</style>

Return to “Highslide JS Usage”