Hi frnds....

I have a page with different topics and explanations....
the total description in a single page..and all headlines at one place...
now iam clicking on nth headline, than the page shows that nth topic description location...
plz tell me how can i do that?

Dani AI

Generated

For a single page that contains many topics, the simplest, most robust approach is to use fragment identifiers (anchors): give each topic a unique id and link to it with #id. The browser will jump to that element automatically (no extra server work required). That is what pointed to and why that reply solved the original problem. Fragment behavior and the location.hash API are documented here: Location.hash.

If links must remain as query strings (for example Index.php?SourceID=20) because external systems generate them, map that parameter to a section on page at load time. Parse the query string with URLSearchParams, find the element (by id or a data-* attribute), and call scrollIntoView() for a smooth jump. Example:

document.addEventListener('DOMContentLoaded', function () {
  const params = new URLSearchParams(location.search);
  const id = params.get('SourceID');
  if (id) {
    const el = document.querySelector('[data-source-id="' + id + '"]');
    if (el) el.scrollIntoView({ behavior: 'smooth' });
  }
});

Server-side alternatives are possible: the page generator can emit a redirect to a fragment URL or print a small inline script that sets location.hash. Note the important point that fragments are client-only and are not sent to the server, so server code cannot read #... from an incoming request.

Quick practical tips: ensure id values are unique and URL-friendly (no spaces), handle the case when the target isn't found, and account for fixed headers (use CSS scroll-margin-top or adjust the scroll offset). ’s include-based suggestion is useful when wanting duplicate pages with the same content, but it is a different solution than same-page jumping. For parsing/query APIs see URLSearchParams and for scrolling behavior see Element.scrollIntoView.

Recommended Answers

All 5 Replies

I couldn't exactly understand that description but the title is straight forward. So if you are meaning to have to pages but with the same contents just make the second page contain only the following:

<?
include('firstpage.php');
?>

or even

<?
echo file_get_contents("");
?>

I couldn't exactly understand that description but the title is straight forward. So if you are meaning to have to pages but with the same contents just make the second page contain only the following:

<?
include('firstpage.php');
?>

or even

<?
echo file_get_contents("");
?>

Hi sir,
Sorry 4 inconviniance....i think my communication is not good....

In a single page i need to search a string by using link...that link having querystring like this..

<a href="http://hadco-metal.com/Index.php?SourceID=20">jobs</a>

in this way i have 10 number of links...

when i click on the jobs, than the display location goes to jobs topic...it is also in same page....

plz check with patience...

Thank U...

All hail Daniweb ;) heh.. Cheers!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.