Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window.location.reload AND anchors???

Status
Not open for further replies.

LEICJDN1

Technical User
Nov 27, 2002
201
0
0
GB
HI,

I have a small web based ASP database application to manage my references. Part of the section gives a list of links and date last accessed. When a link is clicked the datbase is updated to the current date and the link displayed in a new window. I also have the following event to ensure the main page is reloaded to refresh the change in date:

Code:
onClick='window.location.reload()'

It would be nice to have the page refresh to the link last clicked for ease of use. The links all have individual anchors.

Is there any way to reload the page to a specific anchor or do I need to call a different JS routine to effect this?

Cheers.
 
try this:
Code:
onClick='javascript:window.reload();'
onClick='javascript:window.location.reload();'

one of the 2!


Regards,

Martin

Gaming Help And Info:
 
Excuse my possible ignorance but how does this allow me to implement reload with focus on a particular anchor?

What I need to do is similar to href='blah.html#thissection' but as the link already contains a href anchor opened in a new window I would like to reload the main window via an onclick event but also send to the appropriate anchor.

Any more advice?
 
If the anchor is already a part of the anchor, you can use:
Code:
onclick="location.href=location.href"
If you want the main window location to match the location of the popup with a click in the popup:
Code:
opener.location.href=location.href
If you want only the anchor name from the pop-up transferred to the opener with a click on the pop-up:
Code:
opener.location.href=opener.location.pathname+opener.location.search+location.hash

Adam
"Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done." Andy Rooney.
 
Oops, the first sentence should read "If the anchor is already a part of the url, you can use:"

Adam
"Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done." Andy Rooney.
 
Fiddled around in the end and came up with this solution:

Code:
onClick=location.href='URL#anchor';

Seems to work.

Cheers all.
 
Ahh, spoke too soon!

It does reload the pager to the correct anchor but it is happening too quickly! What I mean, is that by clicking the link this diverts to an ASP page which updates the date setting in the database and then forwards on to actual link. Trouble is the reload occurs very quickly hence displaying the 'old' date and not the new one.

Can I delay the reload process?
 
Or link it to when the pop up window is complete?
 
Hmmm. Another thought - does the above method using location.href work correctly with an ASP link? What I mean is does it force a genuine refresh with a re-do query of the ASP or just reloaded the client side HTML?

This is getting more complicated than I thought!
 
Sounds like you might need to disable the browser's cache on your main page to keep it from displaying the old date.

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top