473,473 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Javascript closes IE

I have the following javascript in my html:
<script language="javascript">
function setfocus()
{
if (document.body.style.cursor="default")
{
document.body.style.cursor="wait";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
else
{
document.body.style.cursor="default";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
}
</script>

In my codebehind I have: Me.btnFind.Attributes.Add("onclick", "setfocus()")

It seems to run fine for at least 2 to 3 clicks and then issues a send error
report dialogue saying:
'Internet Explorer has encountered a problem and needs to close.',
crashing, of course, IE.

I have IE 6 and .NET 2003. I have encountered this on Windows XP Pro,
Windows 2000 Pro and Windows 2000 Server.
I am not a javascript programmer so I have no clue as to why this is
happening.

TIA,
Marc Miller







Nov 18 '05 #1
12 1487
Try renaming the function to something other than setfocus(). You could be
dealing with a reserved word here.

"m miller" <mm*****@epix.net> wrote in message
news:Ow****************@TK2MSFTNGP09.phx.gbl...
I have the following javascript in my html:
<script language="javascript">
function setfocus()
{
if (document.body.style.cursor="default")
{
document.body.style.cursor="wait";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
else
{
document.body.style.cursor="default";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
}
</script>

In my codebehind I have: Me.btnFind.Attributes.Add("onclick", "setfocus()")
It seems to run fine for at least 2 to 3 clicks and then issues a send error report dialogue saying:
'Internet Explorer has encountered a problem and needs to close.',
crashing, of course, IE.

I have IE 6 and .NET 2003. I have encountered this on Windows XP Pro,
Windows 2000 Pro and Windows 2000 Server.
I am not a javascript programmer so I have no clue as to why this is
happening.

TIA,
Marc Miller







Nov 18 '05 #2
Scott,

Good suggestion. I changed the function to hGlass() and I still get the same
behaviour. I also tested with:
document.form1.btnGet.style.cursor="wait";
in lieu of
document.body.style.cursor="wait";

and the same for the 'default' style, and got no errors. It seems to have a
problem with 'document.body.style'

Tks,
Marc Miller



"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
Try renaming the function to something other than setfocus(). You could be dealing with a reserved word here.

"m miller" <mm*****@epix.net> wrote in message
news:Ow****************@TK2MSFTNGP09.phx.gbl...
I have the following javascript in my html:
<script language="javascript">
function setfocus()
{
if (document.body.style.cursor="default")
{
document.body.style.cursor="wait";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
else
{
document.body.style.cursor="default";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
}
</script>

In my codebehind I have: Me.btnFind.Attributes.Add("onclick",

"setfocus()")

It seems to run fine for at least 2 to 3 clicks and then issues a send

error
report dialogue saying:
'Internet Explorer has encountered a problem and needs to close.',
crashing, of course, IE.

I have IE 6 and .NET 2003. I have encountered this on Windows XP Pro,
Windows 2000 Pro and Windows 2000 Server.
I am not a javascript programmer so I have no clue as to why this is
happening.

TIA,
Marc Miller








Nov 18 '05 #3
Hi Marc,

Is "btnFind" a ASP.NET Button control? When you click it, your setfous
method will be executed, however, the page also will be postback and
refresh. If you only want to setfocus to a TextBox, you may use a HTML
button component instead.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
Hi

Well here is 1 error
if (document.body.style.cursor="wait") <-- error
if (document.body.style.cursor == "wait") <-- correct, 2 ==

document.body.style.cursor = (document.body.style.cursor =="wait") ? "auto"
: "wait";
document.forms["Form1"].txtPartno.focus();
document.forms["Form1"].txtPartno.select();

http://msdn.microsoft.com/library/de...ies/cursor.asp

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"m miller" <mm*****@epix.net> wrote in message
news:Ow****************@TK2MSFTNGP09.phx.gbl...
I have the following javascript in my html:
<script language="javascript">
function setfocus()
{
if (document.body.style.cursor="default")
{
document.body.style.cursor="wait";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
else
{
document.body.style.cursor="default";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
}
</script>

In my codebehind I have: Me.btnFind.Attributes.Add("onclick", "setfocus()")
It seems to run fine for at least 2 to 3 clicks and then issues a send error report dialogue saying:
'Internet Explorer has encountered a problem and needs to close.',
crashing, of course, IE.

I have IE 6 and .NET 2003. I have encountered this on Windows XP Pro,
Windows 2000 Pro and Windows 2000 Server.
I am not a javascript programmer so I have no clue as to why this is
happening.

TIA,
Marc Miller







Nov 18 '05 #5
Hi m miller,
Thank you for the response. Since you want to run some client script code
to set the cursor and some entryfields' focus, do you think it possible
that you used the HtmlControl button such as
<input type="button" id="btnFind" value="Find" onclick="setfocus" />

Since the ASP.NET server button will automatically posted back the page to
the serverside, so the "onclick" attribute you add for it won't be able to
run. To use a HtmlControl button, you can simple code it as this:
..............
<script language="javascript">
function setfocus()
{
if (document.body.style.cursor == "default")
{

document.body.style.cursor="wait";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
else
{
document.body.style.cursor="default";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center" border="1">
<tr>
<td><input type="text" id="txtOther" runat="server"></td>
<td><input type="button" id="btnFind" value="Find"
onclick="setfocus()"></td>
</tr>
<tr>
<td><INPUT id="txtPartno" type="text" name="txtPartno"
runat="server"></td>
<td></td>
</tr>
</table>
</form>
....................

Please try out the suggestion and see whether it helps. Also if you have
any questions on it or if my suggestion is not quite suitable for your
situation, please feel free to let me know.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6
Its nice to see the responses...Thanks!

Here's what I have tried.

1. I started with using an ASP.NET button control with :
Me.btnFind.Attributes.Add("onclick","hglass()") in the page_load.
2. I then added an HTML button as well and this is the code for that:

<INPUT id="btnFindHTML" style="Z-INDEX: 110; LEFT: 336px; POSITION:
absolute; TOP: 80px"
type="submit" value="Find" runat="server" onclick="hglass()">

They both call the code:
<script language="javascript">
function hglass(eventobj,obj)
{
if (document.body.style.cursor="default")
{

document.body.style.cursor="wait";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();

}
else
{
document.body.style.cursor="default";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
}
</script>
The code works, but after one or two finds...IE blows up and crashes.

I tried using cursor=="default" in lieu of cursor="default" , but
the code does not execute.

Perhaps I will rebuid this app since the code works in another webapp that I
have.

Thanks for the help,
Marc Miller



"m miller" <mm*****@epix.net> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
Scott,

Good suggestion. I changed the function to hGlass() and I still get the same behaviour. I also tested with:
document.form1.btnGet.style.cursor="wait";
in lieu of
document.body.style.cursor="wait";

and the same for the 'default' style, and got no errors. It seems to have a problem with 'document.body.style'

Tks,
Marc Miller



"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
Try renaming the function to something other than setfocus(). You could

be
dealing with a reserved word here.

"m miller" <mm*****@epix.net> wrote in message
news:Ow****************@TK2MSFTNGP09.phx.gbl...
I have the following javascript in my html:
<script language="javascript">
function setfocus()
{
if (document.body.style.cursor="default")
{
document.body.style.cursor="wait";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
else
{
document.body.style.cursor="default";
document.Form1.txtPartno.focus();
document.Form1.txtPartno.select();
}
}
</script>

In my codebehind I have: Me.btnFind.Attributes.Add("onclick",

"setfocus()")

It seems to run fine for at least 2 to 3 clicks and then issues a send

error
report dialogue saying:
'Internet Explorer has encountered a problem and needs to close.',
crashing, of course, IE.

I have IE 6 and .NET 2003. I have encountered this on Windows XP Pro,
Windows 2000 Pro and Windows 2000 Server.
I am not a javascript programmer so I have no clue as to why this is
happening.

TIA,
Marc Miller









Nov 18 '05 #7
Hi m miller,

Thanks for your reply. Please try out the following step:
1. remove the "runat=server" attribute in the
<INPUT id="btnFindHTML" style="Z-INDEX: 110; LEFT: 336px; POSITION:
absolute; TOP: 80px"
type="submit" value="Find" runat="server" onclick="hglass()">
Since the html button only call the client script, no need to be posted
back to server.

2. still using the cursor=="default" to compare the cusor's state

Try to see whether it works. Also, as you mentioned that your code works in
another project's certain page. Would you please have a check on that
page's code to see whether there are any differences between that one and
the page has error? I'm looking forward to your update.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #8
Steven,

The button needs to runat="server" because there is codebehind (VB) click
event where it goes out to Oracle and retrieves the data.
This is why I need an hourglass, because the query takes about 30 to 40
seconds to return the subset.

Marc

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:OC**************@cpmsftngxa07.phx.gbl...
Hi m miller,

Thanks for your reply. Please try out the following step:
1. remove the "runat=server" attribute in the
<INPUT id="btnFindHTML" style="Z-INDEX: 110; LEFT: 336px; POSITION:
absolute; TOP: 80px"
type="submit" value="Find" runat="server" onclick="hglass()">
Since the html button only call the client script, no need to be posted
back to server.

2. still using the cursor=="default" to compare the cusor's state

Try to see whether it works. Also, as you mentioned that your code works in another project's certain page. Would you please have a check on that
page's code to see whether there are any differences between that one and
the page has error? I'm looking forward to your update.
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #9
Hi m miller,

Thank you for the response. I think I've got your definite requirement, you
have to do some data retrieving operation which may take some pieces of
time when the ServerControl button is clicked. Since the operation won't be
finished in a short time, you want to set the client's cursor state to
"wait". I've done some further test on my side and you may try out the
following code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>CursorTest</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function ChangeCursor()
{
//alert(document.body.style.cursor)

if (document.body.style.cursor == "wait")
{
document.body.style.cursor="default";
document.Form1.txt2.focus();

}
else
{
document.body.style.cursor="wait";
document.Form1.txt2.focus();
}

}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" border="1" align="center">
<tr>
<td><INPUT id="txt1" type="text" runat="server"></td>
<td></td>
</tr>
<tr>
<td><FONT face="ËÎÌå"><INPUT id="txt2" type="text"
runat="server"></FONT></td>
<td>
<asp:Button id="btnServer" runat="server" Text="Server
Button"></asp:Button></td>
</tr>
</table>
</form>
</body>
</HTML>

---------------------code behind---------------------
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

btnServer.Attributes.Add("onclick","ChangeCursor() ");
}
private void btnServer_Click(object sender, System.EventArgs e)
{
System.Threading.Thread.Sleep(1000*10);
Response.Write("<br>Server Button is clicked at:"+
DateTime.Now.ToLongTimeString());
}

Notice that the "document.body.style.cursor" is empty at first, so we can
check the cursor state like:
if (document.body.style.cursor == "wait")
{.......}else{.......}

And I use "System.Threading.Thread.Sleep(1000*10);" in the Serverside
button's click event to simulate the long time Data retrieving operation
you mentioned.

Hope it is helpful. If you have any question on it ,please feel free to
let me know.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #10
Hi Marc,

From your description, the problem is related to other components on the
same web form. A simple way to test this is adding an ASP.NET button on the
web form, in its code behind, adding following code:

System.Threading.Thread.Sleep(1000 * 10)

And then click it for 3~4 to see if it also will generate such error. If
so, you may check if there are sepcial components or code in the web form.
For example, are there some activex control, script block or ASP.NET
control on the web form. You may try to temporarily remove them from the
web form and test again to confirm.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #11
I thank you for all your help. I did try the
System.Threading.Thread.Sleep(1000 * 10) from a test web form and it worked
well.
I then put it at the beginning of my btnFind_Click and a RETURN after it
and it crashed IE.

I then rebuilt the application in a new project, thru cut and paste. It now
works fine. The new project has all the elements of the
old project, help web forms, jpg's etc.

We may never know......

Marc Miller


"MSFT" <lu******@online.microsoft.com> wrote in message
news:U4**************@cpmsftngxa07.phx.gbl...
Hi Marc,

From your description, the problem is related to other components on the
same web form. A simple way to test this is adding an ASP.NET button on the web form, in its code behind, adding following code:

System.Threading.Thread.Sleep(1000 * 10)

And then click it for 3~4 to see if it also will generate such error. If
so, you may check if there are sepcial components or code in the web form.
For example, are there some activex control, script block or ASP.NET
control on the web form. You may try to temporarily remove them from the
web form and test again to confirm.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #12
I am having the same problem. IE crashes after 2 or three clicks

David

"MSFT" <lu******@online.microsoft.com> wrote in message
news:U4**************@cpmsftngxa07.phx.gbl...
Hi Marc,

From your description, the problem is related to other components on the
same web form. A simple way to test this is adding an ASP.NET button on the web form, in its code behind, adding following code:

System.Threading.Thread.Sleep(1000 * 10)

And then click it for 3~4 to see if it also will generate such error. If
so, you may check if there are sepcial components or code in the web form.
For example, are there some activex control, script block or ASP.NET
control on the web form. You may try to temporarily remove them from the
web form and test again to confirm.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #13

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

Similar topics

1
by: Al C. | last post by:
Is there a technique for this? Take a standard order-entry. You have your "header" info with the PO number, and Tax rate, etc. and then you have one to many item lines. Currently I do it all on...
7
by: JZ | last post by:
I hope there is someone out there that can suggest a solution to my problem. So here we go: $command="myapp.exe -P d:\mydir\mySubDir"; echo "<td><a...
16
by: Safalra | last post by:
Frequently in ciwah people say 'but what about the users without JavaScript?', so I decided to do an experiment. It suggests 35% internet users do not have JavaScript turned on in their browsers....
6
by: Denis | last post by:
I am trying to launch an .mdb file via javascript. I do not need to do anything but open the application. It is able to open the application but for some reason it opens and then closes. At...
8
by: Brent_White_99 | last post by:
I copied the code from another HTML script that someone before me had written. I have no Javascript experience (I'm a VB Programmer/DBA) at all. The code below works to a certain extent. There...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
1
by: thomas.humberset | last post by:
Hello! Could someone please help me on the following case. I have a page that opens a popup/child-window (window.open(...)). This childwindow redirects the mainwindow and closes itself if...
2
by: Ana MB | last post by:
Hi, I'm not very experienced at using javascript, so if there is a better way of doing this than using js feel free to suggest it. Where I am: I've got a pop up slideshow, where people click...
2
by: gsherp | last post by:
How does one execute code when the user closes the browers window by clicking on the top right corner . I need to log out user and do a database write when the user closes the brower. I do these to...
7
by: Sheena777 | last post by:
How can i catch a close event on a web page without the use of javascript. I have a site that a users has to log in to and from that I have to keep track of if they are logged in or not. My problem...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
1
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...
0
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.