Jump to content

anchor tags when ? in url


fohanlon

Recommended Posts

Hi Guys

 

I want to create anchor tags.  I know how to do this with html.  Here is my problem:

 

<a href="#myanchor">Go to my anchor</a>

 

Then I have the <a name set up

 

But the page reloads with a url as follows:

 

mypage.php?id=19#myanchor

 

Where id is an id of a page in a mysql db to pull content.

 

I have a mod rewrite so the above url is mypage/19#myanchor

 

Any help to solve this word be appreciated

 

thanks

 

Fergal.

 

 

This is not working

Link to comment
https://forums.phpfreaks.com/topic/173508-anchor-tags-when-in-url/
Share on other sites

Okay so my understanding is that you want the page to scroll to the anchor after it's been compiled by php. Yes?

 

I'm not an expert but it sounds as though you need a client side function to interact with the page once it's been generated. This ( afain ) cannot be done with php which is sever side, you should try javascript or something that works on the client side.

 

Mootools has a nice smooth scroll function in it's 'More' module.

http://mootools.net/

<script>
   function toggleSections(section)
{
    document.getElementById(section).style.display = "block";
            
    document.remember_page.my_value.value = section;
    document.remember_page.submit();

    return false;
}

function onload_remember_page()
{
  	// always store the current page on page load
    document.remember_page.my_value.value = "details";
    document.remember_page.submit();
  }

</script>
<a href="#details" onclick="toggleSections('details_57');return false; " >show</a>

<div id="details_57" style="display: none" >hidden stuff here</div>

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.