How can I write to a file to the client with Javascript?

Nitesh Naveen

Basically, you cannot write to the client machine directly from the browser as that violates browser security. Such a facility would permit anyone to write a virus in Javascript that could infect your machine when you open a webpage.

You can however write to a cookie using javascript if you just want temporary storage:

// Create a cookie with the specified name and value.
function SetCookie(sName, sValue)
  date = new Date();
  document.cookie = sName + "=" + escape(sValue) + 
    "; expires=" + date.toGMTString();
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact