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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlinks 1

Status
Not open for further replies.

Sunil606

Programmer
Dec 8, 2003
27
GB
Hi
Does anybody have an idea of how to refresh hyperlinks using Javascript?
Some code?

Thanks in advance
 
Sunil,

I'm not quite sure what you mean by "refresh hyperlinks".

Do you mean refresh a document by clicking on a hyperlink?

Or maybe you mean you want to change the HREF that a hyperlink points to using JavaScript?

Or even change the onscreen text that is hyperlinked using JavaScript?

If you can be more precise, I could most likely help you out.

Dan
 
Or maybe it regards resetting onmouseover effects? :)

----------
I'm willing to trade custom scripts for... [see profile]
 

Try a massage.

They'll be sitting there happily on the page for days, saying "Man, I feel *so* refreshed."
 
Hi Dan

I am sorry that I was not specific. I have an ASP application and what I would like to do is refresh the hyperlinks after they have back into the application having logged out. If there is a technique for doing this and you know then your help would be most appreciated.

Kind regards Sunil
 
Sunil,

I still don't understand what you mean by refreshing the hyperlinks. You'll need to try and explain what you mean.

Dan
 
you mean keep the visited links from having the "visited" link color?

if so, this is controlled by the browser's setting for how long to cache the history, and not available to javascript.

what you can do however is use css to control the look of your links - this will make all links blue, always:

<style type=&quot;text/css&quot;>
a {color:#0000ff;}
</style>

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
By reading the other threads you have started, I will assume that your question could be rephrased:

&quot;I wish to keep the colour of the hyperlinks the same regardless of whether the user has visited the link or not.&quot;

If this is indeed what you are asking, then you could include the following CSS definition in the <head> section of your html page:

Code:
<style type=&quot;text/css&quot;>
a:link, a:visited {color:#cc3322;}
</style>

This will ensure they stay the same color regardless.

Jeff

PS: The massage does sound like a better option, however.
 
Hi
When a person clicks on a link it changes colour to show that they have visited a particular link. When a link has not been visitied it remains blue and a visited link is purple; so by refreshing i mean that When a user logs back in to the application I would like to set ALL links to be blue. I hope i am more clear on this occassion.

Sunil
 
How about having 2 classes assign one on reload/refresh
the other onClick like:

Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<html><head><title>TEST</title>
<style type=&quot;text/css&quot;>
<!--
.nw{text-decoration: none; color: #0000FF;}
.vis{text-decoration: none; color: #FF00FF;}
-->
</style></head><body>
<a href=&quot;[URL unfurl="true"]http://www.msn.com&quot;[/URL] target=&quot;_blank&quot; class='nw' 
onClick=&quot;this.className='vis';&quot;>GO</a>
</body></html>

2b||!2b
 
I do not know a way of maintaining the blue/purple colors and then forcing them to be all reset next time they visit.

My code above will keep them all the same color no matter what... this would seem an ideal workaround.

Jeff

PS: Apologies jemminger... our posts are all but the same... you just snuck in before me *grin*
 
if you really want to increase the complexity of your app for not much more than cosmetic gain, you can go server-side since you're already using asp.

make a database table for your links, one for your users, and a join table for the two with a visited flag. upon each page view, check the join table to see if the user has &quot;seen&quot; this link yet, and render the appropriate color.

my advice is just force all links to one color with css.



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Maybe you could timestamp all your links. I know it'll work in Mozilla, but I'm not sure about IE.

Code:
window.onload = function() {

	var date = new Date();
	var stamp = date.getMonth() + &quot;-&quot; + date.getDay() + &quot;-&quot; + date.getHours();

        els = document.getElementsByTagName( &quot;a&quot; );
        for( var i=0; i < els.length; i++ ) {

                els[ i ].href += &quot;?&quot; + stamp;
        }
}

JS is a shitty tool for this though. Usually I'd tell ya to do it with a session ID.

HTH.

PS The code above uses month-day-hours, but you could just change that to whatever you want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top