Link Visited Color and Reading / Writing Cookies

C

Chad

It looks to me as though IE does not dependably display the visited color
for a hyperlink if the hyperlink opens the target source ina new window.
(See short HTML example below). Though the URL is being added to teh history
cache, when the pg is refreshed, the links which open a new window do not
always show that they were visited. Try my example below. By the way, this
seems to work in Firefox.

If this is a bug as it appears to me, is there a work around?

The work around I am considering is to simulate a real hyperlink (anchor)
using a DIV and to use local Javascript to open the window. The javascript
would also write a cookie to keep track of whether the link was visited.
This seems to work but I have a concern: Though I read that IE places cookie
information in a separate file for each cookie, when I look, it seems to be
creating a single file for all cookies. When the cookie expires, the cookie
text still remains in the file.

My concern is that the file will continue to grow and that it could start to
impact performance (eventually!). If the cookies were stored in separate
files, I would not have a concern since IE should remove old cookies once
the max alloted space for COOKIES has been reached. But what happens when
all the cookies are in one file? IE would not be able to delete the file
since the file as a whole wopuld continue to be accessed daily.

Suggestions please?
-Chad

---------------------------
<script language="Javascript">


function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else
{
var expires = "";
}
var ck = name+"="+value+expires+"; path=/";
//if (days != -1) alert('Cookie\n' + ck + '\ncreated');
document.cookie = ck;
}

function funcLinkTo(DIV, strCookieName, strUrl)
{
DIV.className="Visited"; <!--Makes the DIV label (which is
doubling as a fake Anchor) look like a visted hyperlink-->
createCookie(strCookieName,'1',7); <!--Creates a cookie with a cookie
name = the URL. The value is irrelevant. Set to 1 to indicate "visited" -->
window.open(strUrl,""); <!--clicking on the label should
result in the URL opening in a new Window. Thelast opened window of this
type is not reused. -->
}

</script>

<body>
<div title="Click here to go to WebCOINS" valign="middle" class="normal"
onclick="Javascript=funcLinkTo(this, 'OI_Detail00156540',
'http://useaihp280:8080/espweb/servl...=5002&user=Web3&datagroup=cain&key1=156540');"><font
size="2">00156540</font></div>
</body>



---------------------
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Window</title>
</head>

<body>
<span lang="en-us"><b>Ensure Internet History &gt; 0 days. Clear to
retest.</b></span><p>
<b>New Window (Bad):</b></p>
<p><a href="http://www.cnn.com" target="_blank">CNN</a></p>
<p></p>
<a href="http://www.microsoft.com" target="_blank">MS</a><p></p>
<a href="http://www.msnbc.com" target="_blank">MSNBC</a><p></p>
<a href="http://www.wallstreetjournal.com" target="_blank">Wall
Street</a><p>&nbsp;</p>
<p></p>
<p><b>Same Window (Good): </b></p>
<p></p>
<a href="http://abcnews.go.com/">ABC</a><p></p>
<a href="http://www.aljazeera.com/">Al-jazeera</a><p></p>
<a href="http://www.latimes.com//">LA Times</a><p></p>
<a href="http://www.foxnews.com">FOX</a><p></p>

</body>

</html>

----------

function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca;
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
 
C

Chad

Also, in IE, on the Tools, Privacy-->Advanced Properies page, I set
"Override Auto handling", "Block" and "Block" to block cookies, to test what
would happen if a user disabled cooies. Yet, the cookie appears.

This is an Intrnet site that I am working on, if that is relevant. I have
default security settings for all zones.

Can anyone tell me why the cookies are being accepted dispite the fact that
I thought I told IE not to accept them?

This also works in Firefox. Is this also a bug or am I misisng something?



Chad said:
It looks to me as though IE does not dependably display the visited color
for a hyperlink if the hyperlink opens the target source ina new window.
(See short HTML example below). Though the URL is being added to teh
history cache, when the pg is refreshed, the links which open a new window
do not always show that they were visited. Try my example below. By the
way, this seems to work in Firefox.

If this is a bug as it appears to me, is there a work around?

The work around I am considering is to simulate a real hyperlink (anchor)
using a DIV and to use local Javascript to open the window. The javascript
would also write a cookie to keep track of whether the link was visited.
This seems to work but I have a concern: Though I read that IE places
cookie information in a separate file for each cookie, when I look, it
seems to be creating a single file for all cookies. When the cookie
expires, the cookie text still remains in the file.

My concern is that the file will continue to grow and that it could start
to impact performance (eventually!). If the cookies were stored in
separate files, I would not have a concern since IE should remove old
cookies once the max alloted space for COOKIES has been reached. But what
happens when all the cookies are in one file? IE would not be able to
delete the file since the file as a whole wopuld continue to be accessed
daily.

Suggestions please?
-Chad

---------------------------
<script language="Javascript">


function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else
{
var expires = "";
}
var ck = name+"="+value+expires+"; path=/";
//if (days != -1) alert('Cookie\n' + ck + '\ncreated');
document.cookie = ck;
}

function funcLinkTo(DIV, strCookieName, strUrl)
{
DIV.className="Visited"; <!--Makes the DIV label (which is
doubling as a fake Anchor) look like a visted hyperlink-->
createCookie(strCookieName,'1',7); <!--Creates a cookie with a cookie
name = the URL. The value is irrelevant. Set to 1 to indicate
"visited" -->
window.open(strUrl,""); <!--clicking on the label should
result in the URL opening in a new Window. Thelast opened window of this
type is not reused. -->
}

</script>

<body>
<div title="Click here to go to WebCOINS" valign="middle" class="normal"
onclick="Javascript=funcLinkTo(this, 'OI_Detail00156540',
'http://useaihp280:8080/espweb/servl...=5002&user=Web3&datagroup=cain&key1=156540');"><font
size="2">00156540</font></div>
</body>



---------------------
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Window</title>
</head>

<body>
<span lang="en-us"><b>Ensure Internet History &gt; 0 days. Clear to
retest.</b></span><p>
<b>New Window (Bad):</b></p>
<p><a href="http://www.cnn.com" target="_blank">CNN</a></p>
<p></p>
<a href="http://www.microsoft.com" target="_blank">MS</a><p></p>
<a href="http://www.msnbc.com" target="_blank">MSNBC</a><p></p>
<a href="http://www.wallstreetjournal.com" target="_blank">Wall
Street</a><p>&nbsp;</p>
<p></p>
<p><b>Same Window (Good): </b></p>
<p></p>
<a href="http://abcnews.go.com/">ABC</a><p></p>
<a href="http://www.aljazeera.com/">Al-jazeera</a><p></p>
<a href="http://www.latimes.com//">LA Times</a><p></p>
<a href="http://www.foxnews.com">FOX</a><p></p>

</body>

</html>

----------

function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca;
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top