document.writeln('<%= MyVBScriptVariable %>');
The basic process that page creation takes is as follows:
1) Browser requests page.
2) Server receives request.
3) Server handles request (aka - gets file).
4) In the case of ASP, if the file has the extension .asp (or other associated extension), the SERVER will execute all ASP code. In executing this ASP code a new page is created in memory (on the server) with all of the values and resulting information from the ASP page.
5) The compiled content from executing the ASP is sent to the requesting browser.
6) The browser renders the page.
An example would be a banking site. After x number of seconds of inactivity, you get a popup that tells you your session is about to expire.
..the final version of the code (contained in an asp page) that worked when called using onunload is:
var MySession = "<%=Session("filestring")%>"
if ((window.opener.location) == 'http://aURL/aPage.asp')//if we've proceeded to the next page
if ((MySession == null) || (MySession == '') || (MySession == ""))//if the page has been closed without setting any session variables
else//the page has been closed with session variables that we want to kill
<%session("filestring") = ""%>;
I used to teach this stuff... but hey... if you think it's working... more power to you.
You can see that there is no reference to any ASP in the final rendered ASP because it's been processed by the server before it is sent to the browser. All you see if the result of the processing of the ASP page.
Well, it works, but not because of the way you have your code... there are right ways to do things, and wrong ways to do things... if you're happy with how it functions, even though it's not right, that's fine... but it's simply an illusion of what is really occurring. Maybe I'm just overly concerned.. in that case, by all means, continue... but it may come back to bite you later...