SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Sep 26, 2007, 09:29 #1
- Join Date
- Nov 2003
- Location
- Bridgeport
- Posts
- 292
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Stop page from going back to top on AJAX call
I've been working on this site:
http://rareoopdvds.com/movie?dvd=947&movie=1441
Below the specs of the movie on the page are tabs which load different content. Clicking a tab will send the page back to the top and load the required data.
How can I prevent the page from popping back up like Apple does on their trailer section or youTube does in their comments?
Thanks
RichRichTestani
-------------------------------
http://www.junkdepot.com
http://www.rareoopdvds.com | The Movie Poster Site
-
Sep 26, 2007, 09:53 #2
- Join Date
- Nov 2004
- Location
- Nelson BC
- Posts
- 2,310
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The tab is actually an <a> tag with href="#"
So, you are capturing the onclick event and processing it using ajax, but you're probably not returning false from the event handler. This would prevent the default action of the link (which is to jump to the top of the page in the case of #).
-
Sep 26, 2007, 10:13 #3
- Join Date
- Oct 2006
- Location
- Kathmandu, Nepal
- Posts
- 4,013
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes exactly do it like this:
Code html:<ul> <li class="detailmenu"><a href="javascript:void(null);" id="details" class="">Details</a></li> <li class="detailmenu active"><a class="active" href="javascript:void(null);" id="amazon">Amazon</a></li> Marketplace</a></li>//--> </ul>
It will solve the problem.Mistakes are proof that you are trying.....
------------------------------------------------------------------------
PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5
-
Sep 26, 2007, 10:29 #4
- Join Date
- Nov 2003
- Location
- Bridgeport
- Posts
- 292
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks guys, the javascript:void(null) was the ticket here.
Both comments appreciated.
RichRichTestani
-------------------------------
http://www.junkdepot.com
http://www.rareoopdvds.com | The Movie Poster Site
-
Sep 26, 2007, 15:01 #5
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
That will of course produce a broken link if JavaScript is disabled. If you don't want it to link to somewhere if javaScript is disabled then why are you using an <a> tag to attach the onclick instead of attachhing it to a styled <span> tag.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
Bookmarks