Which is fine. However, what I need to do is when the user clicks on this link to open the window, a cookie is also set with a variable name and a variable value.
To cut a long story short (too late), I need to indicate that a user has read a particular document or not.
Any help will be muchly appreciated.
Regards
bloke
www.blokeinthekitchen.com
Making cooking cool for blokes
1.When a link is clicked..first read cookie to see if this particular value is set already?
2. if not then set a new cookie3. else do not open the document or open the doc - depends on what you want to do...
Here is a simple cookie script...let me know if you are not able to implement it in your situation....
I guess I'll be able to put some together for you..
Post the actual webpages link here...so that I can see your real code and structure and insert the required pieces
Intranet I'm afraid. I want the cookie name to contain the user id and document id (eg BobH4321 - made up of userid BobH & document id 4321) and I guess the value can just be true or 1 or something.
use the following javascript and get rid of the one you already have..(unless there is some more which is not shown in this thread by you.
Code:
<script type="text/javascript">
<!--
var expireIn = 60 * 1000;
var expire = new Date();
var cookieName = "fileName";
function openFile(jsVar){
var userId = "BobH";
var docId = "4321";
var storedFile = GetCookie(cookieName);
if(storedFile!=(userId+docId)){
CreateCookie(userId+docId);
window.open(jsVar, "File", "toolbars=no, scrollbars=yes, height=600, width=450, resizable=yes, left=250, top=70");
}else{
alert("error message that file is already created");
}
}
/*
@param val Value to be put in cookie
*/
function CreateCookie (val) {
//want this cookie to expire in 30 days
//timesVisited +=1;
var thisVisit = new Date();
expire.setTime (expireIn + parseInt(expire.getTime())); //1 mins from now!
var WholeCookie = val;
document.cookie = cookieName+"=" + escape (WholeCookie) + "; expires=" + expire.toGMTString();
}
/*
@param CookieName is passed to get Cookie method to read a cookie
@return returns an array of values in the cookie separated by a ` character.
*/
function GetCookie (CookieName) {
var cname = CookieName + "=";
var i = 0;
while (i < document.cookie.length) {
var j = i + cname.length;
if (document.cookie.substring(i, j) == cname){
var leng = document.cookie.indexOf (";", j);
if (leng == -1) {
leng = document.cookie.length;
}
return (unescape(document.cookie.substring(j, leng))).split("`");
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
}
//-->
</script>
This above will expire in 1 minute
take a look at the top at this line
var expireIn = 60 * 1000;
you will need to change it to the expiration time frame as you need.
You may want to read up at description at this link.
Bookmarks