You are not logged in.

Announcement

Forum database was corrupt and an old backup was restored as temporary replacement. Registrations closed until the database is recovered. Please ask questions using the Contact form

#1 25-04-2013 14:49:21

snikookar
Contributors
Registered: 23-03-2013
Posts: 37

Move to a specific part of page

Hi,

I want to click on one of tile in my site and then go to a specific part of a page (for example go to middle of the page in a specific header).

Could you please let me know how I can do that? How can I address it in the URL part of the title?

Thanks

Offline

#2 25-04-2013 15:10:27

Emil
Moderator
From: in a shipyard
Registered: 15-03-2013
Posts: 106

Re: Move to a specific part of page

use jquery anchors (do a google search on the topic, there are lots of tutorials)


Good advice is often confusing, but example is always clear.

Offline

#3 26-04-2013 12:50:05

snikookar
Contributors
Registered: 23-03-2013
Posts: 37

Re: Move to a specific part of page

Hi,

I could not find a correct solution. I have a page for mobile and when I click on that I want to go to a specific parts of the page (e.g. Test). My url in address bar after clicking on a tile is:
http://localhost:81/mobile.php#!/url=testpage.php#test

but I receive an error about finding a page. I have put <a name="#test"></a> in the middle of testpage.php.

Offline

#4 27-04-2013 11:44:24

Thomas
Administrator
Registered: 10-03-2013
Posts: 897

Re: Move to a specific part of page

add this on the subpage

<script>
$.plugin($afterSubPageShow,{
    scrollPage:function(){
         if($hashed.parts[1]=="test"){
			 $("body, html").animate({scrollTop:$("#test").offset().top},500);  
		 }
    }
});
</script>

this will scroll to the element test if the url is

http://localhost/#!/testpage&test

Offline

#5 27-04-2013 18:28:03

snikookar
Contributors
Registered: 23-03-2013
Posts: 37

Re: Move to a specific part of page

Hi,

Sorry, but it did not work. Nothing happened.

Offline

#6 27-04-2013 18:29:23

Thomas
Administrator
Registered: 10-03-2013
Posts: 897

Re: Move to a specific part of page

Hmm, I tested it. Do you have an element with ID "test" on your page?

Offline

#7 27-04-2013 18:30:36

snikookar
Contributors
Registered: 23-03-2013
Posts: 37

Re: Move to a specific part of page

I also have below URL
http://localhost:81/#!/url=testpage.php&test

Offline

#8 27-04-2013 18:37:26

Thomas
Administrator
Registered: 10-03-2013
Posts: 897

Re: Move to a specific part of page

shouldn't give a problem, but do you have an element with the id "test" on your page?

Offline

#9 28-04-2013 07:25:08

snikookar
Contributors
Registered: 23-03-2013
Posts: 37

Re: Move to a specific part of page

Hi,
Yes, it works :-)

Insert the tag below in the page:
<a id="test">

Insert the script below as well:
<script>
$.plugin($afterSubPageShow,{
    scrollPage:function(){
    $('html,body').animate({scrollTop: $("#"+$hashed.parts[1]).offset().top},'slow');
    }
});
</script>

Call the page by: http://localhost:81/#!/url=testpage.php&test

Many thanks.

Offline

Board footer

Powered by FluxBB