Welcome Guest, Not a member yet? Register   Sign In
Linking to a named anchor?
#1

[eluser]foyer[/eluser]
I was hoping someone could help me. If I am using a url suffix from my configuration. How do I use <a name="goto"> and add #goto after the url suffix with the anchor() function?
#2

[eluser]LuckyFella73[/eluser]
Did you try to set up the anchor function this way?

Code:
&lt;?php echo anchor(current_url().'#goto', 'LinkText'); ?&gt;
#3

[eluser]TheFuzzy0ne[/eluser]
You can instead set the ID attribute for the element, and access it the same way as you would a named anchor.

Code:
<div id="myDiv">
Some text
</div>

Scroll to this div using: http://mysite.tld/#myDiv (or whatever the current URL is).
#4

[eluser]foyer[/eluser]
[quote author="LuckyFella73" date="1237390256"]Did you try to set up the anchor function this way?

Code:
&lt;?php echo anchor(current_url().'#goto', 'LinkText'); ?&gt;
[/quote]

how exactly is this any different?
#5

[eluser]TheFuzzy0ne[/eluser]
[quote author="foyer" date="1237412013"]how exactly is this any different?[/quote]

Because if you don't use the current URL, the anchor function will just prepend the base URL, without any segments.

Try it, you might be pleasantly surprised.
#6

[eluser]foyer[/eluser]
Yes indeed, thanks guys




Theme © iAndrew 2016 - Forum software by © MyBB