jQuery URL actions -


hy,

i have menu this:

<a href=home>home</a> - <a href=home/sub1>home sub 1</a> - <a href=home/sub2>home sub 2</a> - <a href=home/sub3>home sub 3</a>  <a href=garden>garden</a> - <a href=garden/sub1>garden sub 1</a> - <a href=garden/sub2>garden sub 2</a> - <a href=garden/sub3>garden sub 3</a> 

now set link url:

$.address.init(function(event) {  $('a').address(function() {return $(this).attr('href').replace(location.pathname, '');});}).change(function(event) {    var text = (event.value == '') ? 'home' :    event.pathnames[0].substr(0, 1).touppercase() +    event.pathnames[0].substr(1);   $('a').each(function() {   $(this).toggleclass('selected', $(this).text() == text);   });  }) 

so if click "home" url --> www.web.com/#/home , on home sub 1 --> www.web.com/#/home/sub1.

  1. how replace unwanted "/#/"?
  2. how can read actual url , if matches eg: www.web.com/garden/sub1 take action? want use if people come website specific link, actual navigation point should open.

thx

you can manipulate url javascript using window.location.href property, trigger page reload; fortunately can use window.location.hash property. hash property used fragment identifiers, optional components of urls came after hash character (#). string comes after hash character not sent server; therefore, browser responsible restoring state through client scripts, , retrieving appropriate views. because normal links, within single page, no page reload occurs, , browser behaves if have clicked standard link, adding urls list of visited urls. enables history navigation, bookmarking , sharing urls other people.

source: http://blogs.southworks.net/jdominguez/2010/02/the-single-page-interface-pattern/


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -