Using a link from a referring page to open a tab on another page
#1
Posted 29 July 2011 - 09:50 AM
My Target Page
<ul id="tabs" class="tabs">
<li><a href="#learning"><span>Learning styles</span></a></li>
<li><a href="#room"><span>Room type</span></a></li>
<li><a href="#products"><span>Products</span></a></li>
</ul>
<div id="learning">
content
</div>
<div id="room">
content
</div>
<div id="products">
content
</div>
My Referring Page
<a href="search.jtp#products">
When clicked the link launches the target page with the products tab opened BRILLIANT.
HOWEVER it jumps to the end/bottom of the containing div - which happens to be well below the fold.
What i need is for it to jump open the the tab and stay at the top ie so the tabs are visible.
Can this be easily achieved. I might be able to use AJAX but im no whizz with this and have tried but failed miserably.
Any help would be greatly appreciated.
#2
Posted 29 July 2011 - 02:21 PM
the '#products' takes you to a bookmark in that page. I just bet that wherever you land, you'll find an id="products' - which functions as a bookmark.
#3
Posted 04 August 2011 - 10:29 AM
This isnt helpful.
#5
Posted 04 August 2011 - 10:43 AM
pnmorrison, on 04 August 2011 - 10:30 AM, said:
That's always a possibility, but we try.
Is there a link to that page, that would definitely help getting the complete picture.
Until then, my answer stands - the '#product" is a link to a BOOKMARK and it takes you to your <div id="products">
So humor me and remove #product from your link and see what happens.
#6
Posted 04 August 2011 - 10:44 AM
It may be as simple as adding this bit of Javascript to the document, but you'd have to test/experiment:
<script type="text/javascript">
window.scrollTo(0,0);
</script>
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#7
Posted 04 August 2011 - 10:50 AM
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#8
Posted 04 August 2011 - 11:22 AM
Ben, on 04 August 2011 - 10:50 AM, said:
Thanks for the detail. Apparently, I overlooked the jquery tabs part - which I know nothing about anyway.
#9
Posted 08 August 2011 - 03:09 AM
#10
Posted 08 August 2011 - 03:11 AM
the scrolling js works as intended i guess in that it moves to the top of the containing div.
it would be perfect if i could show the actual tab/button in the viewing area as well. the top of the screen cuts this off.
i think the solution would be to open the products tab first and then scroll to the top of the page - that way you can see the tab/button which pertains to the content in the containing div - if only i knew how.
#11
Posted 08 August 2011 - 04:56 AM
http://equanet.merus.co.uk/edu/
click on the second option (IT manager) which goes to search.jtp#products
on the target page (search.jtp) you can see that you still need to scroll up a little to see the products tab/button.
#12
Posted 08 August 2011 - 07:37 AM
<script type="text/javascript">
window.scrollTo(0,0);
</script>
would move the user to the top of the page, but I guess it only moves them to the top of that div. Have you tried using a negative number?
<script type="text/javascript">
window.scrollTo(0,-300);
</script>
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#13
Posted 08 August 2011 - 10:28 AM
i think it is obeying the js in that it is scrolling to the top but then the anchor overides it
#14
Posted 15 August 2011 - 09:23 AM
#16
Posted 15 August 2011 - 09:47 AM
thank you so kindly.
#17
Posted 15 August 2011 - 10:40 AM
#18
Posted 15 August 2011 - 11:24 AM
One catch -- it seems like a link to an anchor that exists within the current page doesn't refresh the page, just moves the page into a position. However, an external link to the anchor from a different page works -- the Javascript I've added moves the page back up to the top. Hopefully this works for you?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">#test { background: red; }</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
window.scrollTo(0,0);
});
</script>
</head>
<body>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p id="test"><b>test</b></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
</body>
</html>
Skills: Photoshop, Illustrator, HTML, CSS, jQuery, PHP and CodeIgniter
#19
Posted 17 August 2011 - 06:09 AM
i couldnt express how appreciative i am for this.
thank you soooooooooooooooooo much.
#20
Posted 11 January 2012 - 02:27 PM
This is all awesome, had the same problem. I needed to link from a page to a tab but still have the browser open to the top of the page and not to the top of the selected tab.
Only problem is it only seems to work in Firefox?

Help














