471,085 Members | 1,071 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,085 software developers and data experts.

is there a way to reset link states

Is there any way to reset a link's state. In other words reset a visited
link to an unvisited link. I guess the question I'm asking would be how do
you programatically search and clear the history of a particular page?
Oct 30 '05 #1
6 3619
VK

JimO wrote:
Is there any way to reset a link's state. In other words reset a visited
link to an unvisited link. I guess the question I'm asking would be how do
you programatically search and clear the history of a particular page?


You cannot access cache within the regular security restrictions. Why
would not set link styles equal for both visited and unvisited?

Oct 30 '05 #2
I'm actually writing on-line CSS curriculum for my High School web class.
I'm doing a lesson on psuedo-classes and was looking for a way that I can
reset the links to demonstrate how the different declarations work whenever
a kid reloads the page.

"VK" <sc**********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

JimO wrote:
Is there any way to reset a link's state. In other words reset a visited link to an unvisited link. I guess the question I'm asking would be how do you programatically search and clear the history of a particular page?


You cannot access cache within the regular security restrictions. Why
would not set link styles equal for both visited and unvisited?

Oct 30 '05 #3

"JimO" <jo********************@earthlink.net> wrote in message
news:82*****************@newsread1.news.pas.earthl ink.net...
I'm actually writing on-line CSS curriculum for my High School web
class.
I'm doing a lesson on psuedo-classes and was looking for a way that
I can
reset the links to demonstrate how the different declarations work
whenever
a kid reloads the page.


Jim,

You could try using different links each time the page loads. Use js
to append a random querystring to each URL (assuming the original
hrefs do not already have one....)

Untested but I think that should be enough for the browser to see them
as new links.

Tim.
Oct 30 '05 #4
VK
JimO wrote:
I'm actually writing on-line CSS curriculum for my High School web class.
I'm doing a lesson on psuedo-classes and was looking for a way that I can
reset the links to demonstrate how the different declarations work whenever
a kid reloads the page.


This task is not such trivia and depending on the level of your class
you may want to choose a set of separate pages instead.

Pseudo-classes are not directly exposed for scripting: thus you cannot
apply something like linkObject.style.aHoverColor = newColor;

The way around it is in using imported style sheets and switching them
at runtime. This approach is demonstrated below. Please not that:

1) It doesn't work for all browsers (actually tested on IE only). See
<http://alistapart.com/articles/alternate/> for other solutions. They
are all based on the same idea but using other methods.

2) You have to create two additional files defaultLinkStyles.css and
newLinkStyles.css
Their content follows the page text.
// HTML Page
<html>
<head>
<title>Dynamic Link Style</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<style type="text/css">
@import url('defaultLinkStyles.css');
body { background-color: #FFFFFF;}
p { font: 10pt Verdana, Geneva, sans-serif}
</style>

<script style="text/javascript">
function f1() {
try {
document.styleSheets[0].imports[0].href =
'newLinkStyles.css';
}
catch (e) {
alert(e.description);
}
}
</script>

</head>

<body bgcolor="#FFFFFF">

<p><a href="http://www.google.com">http://www.google.com</a></p>
<p><a
href="http://www.For_Sure_Not_Viewed_Yet.com">http://www.For_Sure_Not_Viewed_Yet.com</a></p>
<p><a
href="http://groups.google.com/group/comp.infosystems.www.authoring.stylesheets?lnk=li& amp;hl=en">comp.infosystems.www.authoring.styleshe ets</a></p>

<form method="post" action="">
<input type="button" name="b01" value="Switch" onclick="f1()">
</form>

</body>
</html>
// defaultLinkStyles.css
a:active { color: #FF0000; text-decoration: underline}
/* a:visited color rule has higher priority over
a:hover if viewed from your local drive.
To fix this bug (feature?) one should use
additional !important instruction: */
a:hover { color: #FF0000 !important; text-decoration: underline}
a:link { color: #0000FF; text-decoration: underline}
a:visited { color: #800080; ; text-decoration: underline}
// newLinkStyles.css
a:active { color: #000000; text-decoration: underline}
/* a:visited color rule has higher priority over
a:hover if viewed from your local drive.
To fix this bug (feature?) one should use
additional !important instruction: */
a:hover { color: #00FF00 !important; text-decoration: underline}
a:link { color: #FF0000; text-decoration: underline}
a:visited { color: #FFFF00; ; text-decoration: underline}

Oct 30 '05 #5
VK wrote:
Why would not set link styles equal for both visited and unvisited?


Because that is one of the most incompetent things a Web site responsible
could do.
PointedEars
Oct 30 '05 #6
VK
VK wrote:
/* a:visited color rule has higher priority over
a:hover if viewed from your local drive.
To fix this bug (feature?) one should use
additional !important instruction: */
a:hover { color: #FF0000 !important; text-decoration: underline}

<http://groups.google.com/group/comp.infosystems.www.authoring.stylesheets/browse_frm/thread/936a815501359f6b/acf6ca9f1904599c?hl=en&>

Oct 31 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Stewart Midwinter | last post: by
6 posts views Thread by Shabam | last post: by
reply views Thread by Grant Rettke | last post: by
26 posts views Thread by Mica Cooper | last post: by
4 posts views Thread by news.internode.on.net | last post: by
11 posts views Thread by newbie | last post: by
16 posts views Thread by Giovanni D'Ascola | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.