we building website using restricted cms. thing can manipulate front end - play around template, use custom css , js.
since cannot "memorise" user's choices, came solution pass information via url using hashtags. works smoothly on google chrome , mozilla firefox browsers ie10 strips out hashtag , jquery fails customize page user. here examples on how use thing:
form:
<form action="/name-check/#namecheckpath" method="get" onsubmit="return checkinput(this)"> <input name="gle" type="hidden" value="namecheck" /> <input class="efinputtext_front" id="company_name" name="name" type="text" value="gr4egwergwergehgukykuwegwrg" /> <input class="efsubmitbuttonfront" type="submit" value="check availability" /> </form>
regular links:
<a href="http://www.example.com/package-standard-print/#skipnamecheck">choose</a>
and on...
google chrome behaviour (good):
http://www.example.com/name-check/?gle=namecheck&name=regergergergerger#packthree
ie10 behaviour (bad):
http://www.example.com/name-check/?gle=namecheck&name=gr4egwergwergehgukykuwegwergegergegrrg
what when pick hash:
// find out package dealing var action = window.location.hash.substring(1); switch(action) { case 'namecheckpath': // page of interest: /name-check/ // path: home -> name search -> confirm name -> grid -> package page -> extras -> checkout // needs done: // 1. next page has grid $(".stepactive2").removeclass('stepactive2').addclass('stepinactive2'); $('a[href^="/buy/"]').attr('href', '/package-comparison/#gridskipnamecheck'); $('form[action^="/name-check/"]').attr('action', '/name-check/#namecheckpath'); // 2. steps - remove class second step (package) highlighting works break; case 'packone': // page of interest: /name-check/ // path: home -> choose package (2-5) -> name search -> confirm name -> extras -> checkout // needs done: // 1. next page extras page chosen package $('.stepactive2').text("choose package"); $('.stepinactive3').text("build package"); $('a[href^="/buy/"]').attr('href', '/buy/self-build-flatpack/#selfbuild'); $('form[action^="/name-check/"]').attr('action', '/name-check/#packone'); break; case 'packtwo': // page of interest: /name-check/ // path: home -> choose package (2-5) -> name search -> confirm name -> extras -> checkout // needs done: // 1. next page extras page chosen package $('a[href^="/buy/"]').attr('href', '/buy/basic-digital/'); $('form[action^="/name-check/"]').attr('action', '/name-check/#packtwo'); break; case 'packthree': // page of interest: /name-check/ // path: home -> choose package (2-5) -> name search -> confirm name -> extras -> checkout // needs done: // 1. next page extras page chosen package $('a[href^="/buy/"]').attr('href', '/buy/standard-print/'); $('form[action^="/name-check/"]').attr('action', '/name-check/#packthree'); break; case 'packfour': // page of interest: /name-check/ // path: home -> choose package (2-5) -> name search -> confirm name -> extras -> checkout // needs done: // 1. next page extras page chosen package $('a[href^="/buy/"]').attr('href', '/buy/premium-print/'); $('form[action^="/name-check/"]').attr('action', '/name-check/#packfour'); break; case 'packfive': // page of interest: /name-check/ // path: home -> choose package (2-5) -> name search -> confirm name -> extras -> checkout // needs done: // 1. next page extras page chosen package $('a[href^="/buy/"]').attr('href', '/buy/all-inclusive/'); $('form[action^="/name-check/"]').attr('action', '/name-check/#packfive'); break; case 'gridskipnamecheck': // page of interest: /package-comparison/ // path: home -> name search -> confirm name -> grid -> package page -> extras -> checkout $('a[href^="/package-"]').each(function() { this.href += '#skipnamecheck'; }); break; case 'skipnamecheck': // page of interest: /package-xxx/ // path: home -> name search -> confirm name -> grid -> package page -> extras -> checkout if(window.location.href.indexof("package-self-build") > -1) { $('a[href^="/name-check-"]').attr('href', '/buy/self-build-flatpack/#selfbuild'); } else if(window.location.href.indexof("package-basic-digital") > -1) { $('a[href^="/name-check-"]').attr('href', '/buy/basic-digital/'); } else if(window.location.href.indexof("package-standard-print") > -1) { $('a[href^="/name-check-"]').attr('href', '/buy/standard-print/'); } else if(window.location.href.indexof("package-premium-print") > -1) { $('a[href^="/name-check-"]').attr('href', '/buy/premium-print/'); } else if(window.location.href.indexof("package-all-inclusive") > -1) { $('a[href^="/name-check-"]').attr('href', '/buy/all-inclusive/'); } break; default: //console.log('default'); }
question: why ie10 strip out hashtags? :(
i'm surprised, ff , chrome don't strip out.
the url hash (it's not "hashtag") purely client side feature. it's not sent server @ all.
the browser requests document server using url (without hash) , looks element id matching hash , scrolls it.
see e.g. why hash part of url not in server side? , similar questions.
Comments
Post a Comment