user3587491
user3587491

Reputation:

Javascript/php - After page Refresh, return to page anchor

I have a single page with numerous html anchor points.

I need to refresh the page every 10 seconds to get new incoming data from my database, the page refresh does this.

What I need is if, I am viewing another anchor point which is another page, I wish to be returned to that anchor point after the refresh happens.

Here is what I have, which runs fine but doesn't return me to the anchor I was viewing:

function refresh() {
 if(new Date().getTime() - time >= 10000)
  window.location.reload(true);
}

This above, refresh's the page then returns me to the default anchor point #menu

I have also tried this to be returned to the current view anchor point, but this doesn't work, it won't even run:

function refresh() {
 if(new Date().getTime() - time >= 10000)
  window.location.href = 'driver.php#<?php echo $_SESSION['loc'];?>';
   window.location.reload(true);
}

Also tried it without the php coding it still won't run:

function refresh() {
 if(new Date().getTime() - time >= 10000)
  window.location.href = 'driver.php#show_requests';
   window.location.reload(true);
}

Any help is much appreciated.

Upvotes: 0

Views: 67

Answers (1)

user3587491
user3587491

Reputation:

As I couldn't work out a result to use the one page, I solved the issue by using multiple pages and just set a refresh on each individual page. A bit messy, but it works.

Upvotes: 1

Related Questions