Page 1 of 1

Anchors

Posted: Mon Jun 11, 2007 5:03 pm
by tyman00
I had some issues with HTML anchors not working properly. They would default to index.php#Anchor insead of /index.php?page=Name#Anchor

I wrote a Javascript solution that helped me out and I thought I would share. I am actually using it with pretty url's (domain.com/parent/child#Anchor).

Use the attached JS file (remove the .txt extension). You can either reference the in your template or in specific pages. I did not include it in my Template. I am putting it in the Metadata field under the options tab on just the pages that I am using anchors, with the following code:

Code: Select all

{literal}
<__script__ src="/JS/anchor.js" type="text/javascript"></__script>
{/literal}
To get the anchors to work you need to call the anchor function and pass the anchor name within the function call. Here is how I did it.

Code: Select all

<a href="javascript:anchor('#Top');">^Top</a>
You would replace #Top with your anchor name. Be sure to include the Hash Mark (#) in your anchor name.

I tested it in IE 6, IE 7, Avant 11, Netscape 8.1 (A little buggy), and Firefox 2

Re: Anchors

Posted: Sun Sep 23, 2007 1:16 am
by pixelita
Hmm. I had high hopes for this but I am getting Smarty errors.  This is such a great CMS, but there are a few stumbling blocks and they are annoying, this being one of them. 

UPDATE:  I reluctantly added the JS to the template head and all seems to be fine now. Thanks a bunch!!