473,890 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASPX, VBScript, JavaScript, Double-Underscored Variables and setTimeOut

That subject packs a whallop, so let me explain in better detail what's
happening and how it relates to ASPX pages...

In a [large] nutshell, if the first <script /on a page is of type
"text/vbscript", you cannot use inline JavaScript statements that call
setTimeout with functions that start with a double-underscore. This is
very relavant to ASPX (ASP Dot Net) pages because it means that
AutoPostBacks will fail since they generally call the famous JavaScript
statement "__doPostBack(. ..)" via a setTimeout call.

If you include a VBScript code block before any other code block on an
ASPX page, the following statement will fail in IE (and the error is
far from obvious since it is untrappable and says only that there is an
Invalid character on line 1, character 2):

"javascript:set Timeout('__doPo stBack(\'anyASP Xcontrol\',\'\' )', 0)"

This is a bug in IE 6 and possibly earlier versions (I only have v6 to
play with.) I do not know if it affects IE 7 as I have not installed
that for testing lately. Note that even though the prefix of
"javascript :" is used, the setTimeout function assumes it's calling a
VBScript function, presumably because the first script block is a
VBScript block.

Here is a very simple page that shows this bug:
http://www.digitolle.net/news/testscriptbug.htm

and here is the source code:

--------

<html>
<head>
<title>Test Script Bug</title>
<!-- script type="text/javascript">
// If JavaScript is the first script, setTimeout works properly
// Unrem this script and both buttons will work.
</script -->
<script type="text/vbscript">
' Just because this VBScript block exists,
' setTimeout uses VBScript naming conventions.
' Therefore, double underscore functions will fail
' Rem this block out, and both buttons will work
' Note that calling the function directly always works.
</script>
</head>
<body>
<script type="text/javascript">
function __x() {
alert("test");
}
</script>
<input type="button" value="This will Work"
onclick="javasc ript:__x();" />
<br />
<input type="button" value="This will Fail"
onclick="javasc ript:setTimeout ('__x()', 0);" />
</body>
</html>

--------

The obvious workaround is to always include a JavaScript block before
any VBScript blocks, even if it's just an empty block. If anyone else
comes up with the same results on this test, please let me know. Of
course if this is a known issue and I'm beating a dead horse, again,
please let me know because it's an odd issue to look up and it's
definitely a brain stumper if you don't know it exists.

Aug 9 '06 #1
10 4716
Have you tried setting an emtpy javascript <script... tagset at the beginning?
I seem to recall this as a fix.
peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Shadow Lynx" wrote:
That subject packs a whallop, so let me explain in better detail what's
happening and how it relates to ASPX pages...

In a [large] nutshell, if the first <script /on a page is of type
"text/vbscript", you cannot use inline JavaScript statements that call
setTimeout with functions that start with a double-underscore. This is
very relavant to ASPX (ASP Dot Net) pages because it means that
AutoPostBacks will fail since they generally call the famous JavaScript
statement "__doPostBack(. ..)" via a setTimeout call.

If you include a VBScript code block before any other code block on an
ASPX page, the following statement will fail in IE (and the error is
far from obvious since it is untrappable and says only that there is an
Invalid character on line 1, character 2):

"javascript:set Timeout('__doPo stBack(\'anyASP Xcontrol\',\'\' )', 0)"

This is a bug in IE 6 and possibly earlier versions (I only have v6 to
play with.) I do not know if it affects IE 7 as I have not installed
that for testing lately. Note that even though the prefix of
"javascript :" is used, the setTimeout function assumes it's calling a
VBScript function, presumably because the first script block is a
VBScript block.

Here is a very simple page that shows this bug:
http://www.digitolle.net/news/testscriptbug.htm

and here is the source code:

--------

<html>
<head>
<title>Test Script Bug</title>
<!-- script type="text/javascript">
// If JavaScript is the first script, setTimeout works properly
// Unrem this script and both buttons will work.
</script -->
<script type="text/vbscript">
' Just because this VBScript block exists,
' setTimeout uses VBScript naming conventions.
' Therefore, double underscore functions will fail
' Rem this block out, and both buttons will work
' Note that calling the function directly always works.
</script>
</head>
<body>
<script type="text/javascript">
function __x() {
alert("test");
}
</script>
<input type="button" value="This will Work"
onclick="javasc ript:__x();" />
<br />
<input type="button" value="This will Fail"
onclick="javasc ript:setTimeout ('__x()', 0);" />
</body>
</html>

--------

The obvious workaround is to always include a JavaScript block before
any VBScript blocks, even if it's just an empty block. If anyone else
comes up with the same results on this test, please let me know. Of
course if this is a known issue and I'm beating a dead horse, again,
please let me know because it's an odd issue to look up and it's
definitely a brain stumper if you don't know it exists.

Aug 9 '06 #2
Sorry, I see you've done that. The piece I remember reading said that the
script engine is initialized by the empty script set. No workaround was
provided, that "is" the workaround.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Shadow Lynx" wrote:
That subject packs a whallop, so let me explain in better detail what's
happening and how it relates to ASPX pages...

In a [large] nutshell, if the first <script /on a page is of type
"text/vbscript", you cannot use inline JavaScript statements that call
setTimeout with functions that start with a double-underscore. This is
very relavant to ASPX (ASP Dot Net) pages because it means that
AutoPostBacks will fail since they generally call the famous JavaScript
statement "__doPostBack(. ..)" via a setTimeout call.

If you include a VBScript code block before any other code block on an
ASPX page, the following statement will fail in IE (and the error is
far from obvious since it is untrappable and says only that there is an
Invalid character on line 1, character 2):

"javascript:set Timeout('__doPo stBack(\'anyASP Xcontrol\',\'\' )', 0)"

This is a bug in IE 6 and possibly earlier versions (I only have v6 to
play with.) I do not know if it affects IE 7 as I have not installed
that for testing lately. Note that even though the prefix of
"javascript :" is used, the setTimeout function assumes it's calling a
VBScript function, presumably because the first script block is a
VBScript block.

Here is a very simple page that shows this bug:
http://www.digitolle.net/news/testscriptbug.htm

and here is the source code:

--------

<html>
<head>
<title>Test Script Bug</title>
<!-- script type="text/javascript">
// If JavaScript is the first script, setTimeout works properly
// Unrem this script and both buttons will work.
</script -->
<script type="text/vbscript">
' Just because this VBScript block exists,
' setTimeout uses VBScript naming conventions.
' Therefore, double underscore functions will fail
' Rem this block out, and both buttons will work
' Note that calling the function directly always works.
</script>
</head>
<body>
<script type="text/javascript">
function __x() {
alert("test");
}
</script>
<input type="button" value="This will Work"
onclick="javasc ript:__x();" />
<br />
<input type="button" value="This will Fail"
onclick="javasc ript:setTimeout ('__x()', 0);" />
</body>
</html>

--------

The obvious workaround is to always include a JavaScript block before
any VBScript blocks, even if it's just an empty block. If anyone else
comes up with the same results on this test, please let me know. Of
course if this is a known issue and I'm beating a dead horse, again,
please let me know because it's an odd issue to look up and it's
definitely a brain stumper if you don't know it exists.

Aug 9 '06 #3
Peter wrote:
Sorry, I see you've done that. The piece I remember reading said that the
script engine is initialized by the empty script set. No workaround was
provided, that "is" the workaround.
Now my question is, how long has this bug been around and did they fix
it in IE 7 (which would make me assume that it's not ever going to be
fixed in IE 6). You'd think that with the whole ASPX push, it'd be a
more serious bug to get squashed.

Aug 9 '06 #4
Shadow Lynx said the following on 8/9/2006 11:35 AM:
Peter wrote:
>Sorry, I see you've done that. The piece I remember reading said that the
script engine is initialized by the empty script set. No workaround was
provided, that "is" the workaround.

Now my question is, how long has this bug been around and did they fix
it in IE 7
No, it didn't get "fixed".

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 9 '06 #5
Hi Shadow,
This is not a bug but is by design. Once a particular script language is
declared it is used for the rest of the document.
http://msdn.microsoft.com/library/de...asp?frame=true
If you wish to use JScript statements in the same document then you need to
be specific about the language after the VBScript declaration. You can do
this by setting the language on the element with teh event handler
http://msdn.microsoft.com/library/de...s/language.asp

Thanks
-Dave
"Shadow Lynx" <sh**********@y ahoo.comwrote in message
news:11******** *************@m 79g2000cwm.goog legroups.com...
Peter wrote:
>Sorry, I see you've done that. The piece I remember reading said that the
script engine is initialized by the empty script set. No workaround was
provided, that "is" the workaround.

Now my question is, how long has this bug been around and did they fix
it in IE 7 (which would make me assume that it's not ever going to be
fixed in IE 6). You'd think that with the whole ASPX push, it'd be a
more serious bug to get squashed.

Aug 9 '06 #6
Followup-to set to microsoft.publi c.scripting.jsc ript

Shadow Lynx wrote:

This is a bug in IE 6 and possibly earlier versions (I only have v6 to
play with.)
In IE setTimeout takes a third parameter to indicate the script
language, see
<http://msdn.microsoft. com/library/default.asp?url =/workshop/author/dhtml/reference/methods/settimeout.asp>
So I am not sure the IE developers regard the behavior you see as a bug.
There is a way with setTimeout to indicate a language other than the
default script language (which is decided by the first script element).

And another workaround in JavaScript is to simply pass in a function and
not a string see
<http://home.arcor.de/martin.honnen/javascript/2006/08/test2006080901. html>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 9 '06 #7
Shadow Lynx wrote:
Now my question is, how long has this bug been around and did
they fix it in IE 7 (which would make me assume that it's not
ever going to be fixed in IE 6). You'd think that with the whole
ASPX push, it'd be a more serious bug to get squashed.
I'd hardly call it serious -- much less a bug. Pick a language and stick to
it. You don't demand that IE follow the strict box model for some elements
in a document and quirks mode for others, do you?

If there's any *bug* in the system you describe, it's the introduction of
VBScript to the client-side. If I were MS, I would be in no hurry to make my
aspx pages broken in a significant number of browsers.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Aug 9 '06 #8
"Shadow Lynx" <sh**********@y ahoo.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
: The obvious workaround is to always include a JavaScript block before
: any VBScript blocks, even if it's just an empty block. If anyone else
: comes up with the same results on this test, please let me know. Of
: course if this is a known issue and I'm beating a dead horse, again,
: please let me know because it's an odd issue to look up and it's
: definitely a brain stumper if you don't know it exists.
:

Another workaround is to leave the vbscript block in place (that may be a
neccessity for other reasons) but to wrap the setTimeout function call.

<input type="button" value="This will Fail"
onclick="javasc ript:setTimeout (function(){__x ()}, 0);" />

You can also wrap the function name in brackets to make it acceptable to
VBScript.

<input type="button" value="This will Fail"
onclick="javasc ript:setTimeout ('[__x]()', 0);" />

Or you can you call an external function that in turn calls the problem
function.

function x(){__x();}
<input type="button" value="This will Fail"
onclick="javasc ript:setTimeout ('x()', 0);" />

Aug 9 '06 #9
Dave Anderson wrote:
I'd hardly call it serious -- much less a bug. Pick a language and stick to
it. You don't demand that IE follow the strict box model for some elements
in a document and quirks mode for others, do you?

If there's any *bug* in the system you describe, it's the introduction of
VBScript to the client-side. If I were MS, I would be in no hurry to make my
aspx pages broken in a significant number of browsers.
I actually assumed that it was by design as far as IE was concerned.
The actual "bug" I am referring to is in reference to ASPX.
Specifically, auto-generated client-side code such as
"javascript:set Timeout('__doPo stBack(\'anyASP Xcontrol\',\'\' )', 0)"
will break if a VBScript block is the first script block on the page.
This is, of course, out of my hands as it's an ASPX issue. Microsoft
would need to fix their statement so that the setTimeout function
specifies the JavaScript language.

Please note that Microsoft is not using VBScript for ASPX pages, but I
and others may choose to use VBScript code for various reasons, and if
we do, we can potentially "break" the vast majority of client-side code
generated by ASP.NET and the reason the code stops working isn't all
that obvious.

Aug 9 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6832
by: John Davis | last post by:
When I create new documents in Dreamweaver, there are several choices for ASP creation: ASP JavaScript: run at client side?? ASP VBScript: run at server side?? ASP.NET C# ASP.NET VB I don't understand the differences between ASP JavaScript and ASP VBScript?? Because JavaScript is client-side technology, and ASP is server side technology. I think VBScript is used to implement ASP pages.
29
6043
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
2
8923
by: davidgordon | last post by:
Hi, I have some pages with this VBScript code, which obviously does not work in Firefox. How can I convert this to Javascript in order for my web page to work in Firefox ? It basically fills a drop down with a list of dates that a user can select. Appreciate any help you can offer ----------------------
4
1403
by: Steven Brooks | last post by:
Hi guys A have an ASPX page (a main menu) and from it I need to launch existing exes on the local PC that has invoked the page from IE. I'm thinking that I would have to do this via JavaScript but I can't find how to start another process searching numerous sites. I know .NET has the Process object, can I use this to launch a process on the client side? If so how to I tell .NET that I want the process launched n the client side rather than...
3
1586
by: anoop | last post by:
Hello, How can I use both VBScript and JavaScript on .Aspx page. page has default language as "VB" and in Meta tag defaut client script is VBScript, how can I change the settings, please help, I am new to .dot net.
4
6361
by: korund | last post by:
Is there any difference to read & write to windows Registry with VBScript or JavaScript? Both scripting languages have similar syntax. What is preferable use for this? thanks.
4
5438
Beverly
by: Beverly | last post by:
I have created an .aspx page called ORIValidate.aspx. I want to use an IF/THEN/ELSE/ENDIF VBScript option within the body/HTML section. I am quite sure my problem is with the single or double quotes usage (or lack there of). Here is the code. Could someone please tell me what is wrong here? Thanks much. <% IF Session("sessOriValid") = "FALSE" THEN %> <asp:Label id="AgencyORIInfoInvalid" style="Z-INDEX: 109; LEFT: 160px; POSITION:...
2
4569
by: tunk | last post by:
I dont know where to start my question so let me tell you my story :) The ASP that cause me trouble is running on IIS that set ASP default language to JScript instead of VBScript. This ASP page is popped up by another ASP page and there are authentication, privilege and security stuff involved. And yes this page contain a lot of javascript. there is a <DIV></DIV> in this page for me. And my job is as simple as put another page between...
1
6787
by: David C | last post by:
Can I use VBScript in a aspx page similar to using Javascript for running client code? I assume it would be used in a <scriptblock. This is for a controlled intranet internal application and I'd like to be able to use Word objects using CreateObject() etc. Is that possible, and if so, where can I find more info on it? Thanks. David
2
2817
by: mdock | last post by:
Hello, I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on which the unit was shipped. If the unit was not shipped, obviously there is no order number; the default value of this field on the data table is 0. Herein lies the problem; if the order number is 0, I do not want the grid to display anything. If...
0
9978
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9819
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10811
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10919
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10461
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5846
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4674
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.