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

Using JavaScript Without a Web Server

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello, I have some documentation I want to make available via CD and want to use some JavaScript to enhance it. I am finding that I cannot use cookies (to manually track sessions) etc.

Here are my questions:
1. Can you confirm that cookies are only available interacting with a web server?

2. If cookies require a web server, any ideas on how to have a variable keep it's value when going from one page to another without using a web server?

3. Using JavaScript can I load just an image from the same page without refreshing the page?

Thanks for your time,

Michael

 
Some brief answers:

1.) Supposedly you can set cookies client-side, and I assume you can read them as well. I found this example in the MSDN Library:

<SCRIPT language=&quot;JavaScript&quot;>
<!--
document.cookie = &quot;SomeValueName = Some_Value&quot;;
-->
</SCRIPT>

2.) A better idea for what you are trying to do may be to use frames and cross-frame scripting.

The easiest method might be to have a main page that contains your persistent, global data in <SCRIPT> variables. Then declare an <IFRAME> in that page, into which actions taken by the user cause your script logic to load separate pages to do or show various things.

The <SCRIPT> in your <IFRAME> pages can see all your global data using &quot;
Code:
parent.{varname}
&quot; type constructs. You can even call global subroutines and functions in this manner. This is commonly used in .HTA files, the essence of HTML Applications which you might want to consider using for your purpose. In an .HTA a lot of normal DHTML security restrictions are relaxed or eliminated - but you shouldn't run into cross-frame scripting security problems doing what you have described.

Many people are happy with the HTA intro found here
You need to scroll way down the page to find it, or if the site has been reorganized you might need to start at the home page and hunt for it.

3.) Another possibility is to simply put most of your &quot;page&quot; into a <DIV></DIV> block element, and load different stuff into the <DIV>'s innerHTML property. I believe that nearly any way you can load a new page into document is going to wipe out your script and thus the variable data you've set up.
 
Great suggestions - thanks. I never even thought of using frames.

This forum and it's users are great.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top