Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Anchor tags, and php...why don't they work?


westkoast

Recommended Posts

Basially, our policies page is very long, and we wanted to put some links at the top of the document that would automatically scroll down to the anchored part of the page....

 

In html it worked fine, but now that the pages are all php...for some reason it doesn't work anymore...

 

Any suggestions?

I need to read the rules more often...

Link to comment
Share on other sites

The PHP should not have any effect on that because by the time the page gets to the browser, the PHP has been parsed and the entire document is HTML.

 

Check that you have the proper names and ids in your links and matching entries in your anchor tags.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

Daemonj said it. Check that your quotes are escaped - you may have to put a backslash in front of any quotes or double quotes ( this will depend whether php is echoing a double or single quoted string).

Have a look at the source code of your page, and see what the tags look like, you may need to put " instead of ".

Link to comment
Share on other sites

I found this problem too, it is caused by the use of a <base href=".....> tag being added to the code of most osC pages, so when you click on the anchor link you have defined for example '#pagetop' it takes you to the url defined in the base href with the '#pagetop' tacked to the end.

 

The way I managed to get this working was to use the following code for my link to the anchor:

 

<a href="<?php echo $PHP_SELF."?".$QUERY_STRING; ?>#pagetop">Top of page</a>

 

This may not work with all server configurations though!

 

HTH - Paul

Link to comment
Share on other sites

  • 5 years later...

I like to use

 

<a href="test.php?this=rubbish&#sec5">Section 1 - About this Document</a>

<div id="sec1"></div>

<div id="sec2"></div>

<div id="sec3"></div>

<div id="sec4"></div>

<div id="sec5"></div>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...