CakePHP URL with HTML Anchor
-
18-09-2019 - |
Question
I'm using cakePHP 1.2, and wondering how I can handle a URL that dynamically builds the page with a slug, but then links to the appropriate area with an HTML anchor. An example:
www.mysite.com/pageSlug#anchor
I would parse out the slug, which would be used to dynamically build the page. Once built, I would need to jump to the anchor. Any suggestions on how I could do this?
Thanks!
Solution
It should work if you put anchor name in html code as a name
attribute for <a>
element. The browser will then automatically scroll the page to correct position.
<a name="anchor"></a>
Just generate your page dynamically and put the above fragment to correct place in your code.
Or am I missing something?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow