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
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/

Link to comment
Share on other sites

<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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.