2

i'm trying to create an anchor to a page's element. There's a tab interface. In html i can see that their links are like this:

http://example.com/index.php/service#tab-1
http://example.com/index.php/service#tab-2
http://example.com/index.php/service#tab-3
http://example.com/index.php/service#tab-4

So that i have 4 div's with id's tab-1,tab-2 etc.

How can i create anchor to them from another view file? When i try this:

<a href="<?=site_url();?>/service#tab-1">give it a try</a>

it goes to page /service but not focused on #tab-1 . It was working on plain html, but i couldnt do it with codeigniter

Thanks for help!

dreamend
  • 59
  • 4
  • 19

2 Answers2

2

I just tried the same thing on my CodeIgniter and it worked fine so I suggest double checking your IDs are correct. Other than that try

<a href="<?=site_url('/service#tab-1');?>">give it a try</a>

or

<a href="<?=site_url('/service');?>#tab-1">give it a try</a>
Sam
  • 2,771
  • 2
  • 28
  • 41
0

You need to put the target of #tab-1 etc. in your page. So in your div you need to include a named anchor such as:

<a name="tab-1"></>

This will cause the page to jump to this element.

WoMo
  • 7,136
  • 2
  • 29
  • 36
  • Looking at this thread: http://stackoverflow.com/questions/484719/html-anchors-with-name-or-id It looks like using IDs rather than names is the accepted way to go about this, if I'm not mistaken – Sam Feb 19 '13 at 16:23