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

Javascript executes too soon

Status
Not open for further replies.

TheDrParker

Programmer
Nov 21, 2001
55
US
I have a page that mixes Javascript and VBScript. I do most of my coding in VBScript, but I have to do some in Java because the DTCs are written in Java.
My problem is that the Javascript seems to execute before everything else no matter where I put it. Is there any way to change this or get around it. I just need things to work in a certain order and the Javascript is executing way too early.
BTW: I seem to have to run it on the server because it doesn't like the sessions variables otherwise.
 
The first line of my code is: <%@ Language=VBScript%>

The Lines that execute too soon are: <SCRIPT LANGUAGE=&quot;JavaScript&quot; RUNAT=&quot;server&quot;>

But even if I do
<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;server&quot;>
for the code I want to run sooner the - the Javascript still runs first. It even runs before things I put above the HTML.
 
So even if you put a runat=&quot;server&quot; VBscript above a runat=&quot;server&quot; Javascript....the javascript runs first?

Do you have the buffer enabled or disabled? -Ovatvvon :-Q
 
Try disableing it...it should execute the page from top to bottom then.

Let me know. -Ovatvvon :-Q
 
I took out the Response.Buffer = True and this did not help.
Right below <Body> I put in:

<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;server&quot;>
Response.write(&quot;Check Point1: The VBScript.&quot;)
</Script>

<SCRIPT LANGUAGE=&quot;JavaScript&quot; RUNAT=&quot;server&quot;>
Response.write(&quot;Check Point2: The JavaScript.&quot;)
</Script>

And I get:
Check Point2: The JavaScript.
[More Javascript]
[Rest of page]
Check Point1: The VBScript.

I change the VBScript to:
<%
Response.write(&quot;Check Point1: The VBScript.&quot;)
Response.write(&quot;<BR>&quot;)
%>

I get:
Check Point2: The JavaScript.
[More Javascript]
Check Point1: The VBScript
[Rest of my page]

 
I found that if I set <%@ language=&quot;javascript&quot; %>
all the VBScripts execute first and if I do <%@ language=&quot;vbscript&quot; %> all the javascripts execute first. Any way around this?
 
If you take out the Response.buffer = True...it does not disable it.

If your buffer is enabled through IIS, then it is enabled by default, and you can deactivate it for a page by writing Response.buffer = False. However, if you have it disabled through IIS, you can NOT enable it via script like response.buffer = true.

so, try writing Response.Buffer = False within your page. -Ovatvvon :-Q
 
Actually when I set Buffer to False the page does not even load. I tried it on a simple page that just mixes VBScript and Javascript and the same thing happens.

I resolved my issue by learning more Javascript that I intended to, and just rewrote the necessary code over in Javascript.

If I you any ideas why it works this way I would love to know.

Here's an example of my test page:
<%@ language=&quot;vbscript&quot; %>

<%
Response.Buffer = False
%>

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
</HEAD>
<BODY>

<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>
Response.write(&quot;Check Point1: The VBScript.&quot;)
Response.write(&quot;<BR>&quot;)
Session(&quot;Tester&quot;) = &quot;VBScripter&quot;
</Script>
<SCRIPT LANGUAGE=&quot;JavaScript&quot; RUNAT=&quot;server&quot;>
Response.write(&quot;Check Point2: The JavaScript.&quot;);
Response.write(&quot;<BR>&quot;);
Session('Tester') = &quot;JavaScripter&quot;;
</Script>

<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>
Response.write(&quot;Check Point3: The VBScript.&quot;)
Response.write(&quot;<BR>&quot;)
</Script>
<SCRIPT LANGUAGE=&quot;JavaScript&quot; RUNAT=&quot;server&quot;>
Response.write(&quot;Check Point4: The JavaScript.&quot;);
Response.write(&quot;<BR>&quot;);
</Script>

<SCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>
Response.write(&quot;Check Point3: The VBScript.&quot;)
Response.write(Session(&quot;Tester&quot;))
Response.write(&quot;<BR>&quot;)
</Script>

<SCRIPT LANGUAGE=&quot;JavaScript&quot; RUNAT=&quot;server&quot;>
Response.write(&quot;Check Point4: The JavaScript.&quot;);
Response.write(Session('Tester'));
Response.write(&quot;<BR>&quot;);
</Script>

</BODY>
</HTML>

Thanx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top