473,545 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript closes IE

I have the following javascript in my html:
<script language="javas cript">
function setfocus()
{
if (document.body. style.cursor="d efault")
{
document.body.s tyle.cursor="wa it";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
else
{
document.body.s tyle.cursor="de fault";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
}
</script>

In my codebehind I have: Me.btnFind.Attr ibutes.Add("onc lick", "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 1495
Try renaming the function to something other than setfocus(). You could be
dealing with a reserved word here.

"m miller" <mm*****@epix.n et> wrote in message
news:Ow******** ********@TK2MSF TNGP09.phx.gbl. ..
I have the following javascript in my html:
<script language="javas cript">
function setfocus()
{
if (document.body. style.cursor="d efault")
{
document.body.s tyle.cursor="wa it";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
else
{
document.body.s tyle.cursor="de fault";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
}
</script>

In my codebehind I have: Me.btnFind.Attr ibutes.Add("onc lick", "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.cu rsor="wait";
in lieu of
document.body.s tyle.cursor="wa it";

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******** ******@TK2MSFTN GP09.phx.gbl...
Try renaming the function to something other than setfocus(). You could be dealing with a reserved word here.

"m miller" <mm*****@epix.n et> wrote in message
news:Ow******** ********@TK2MSF TNGP09.phx.gbl. ..
I have the following javascript in my html:
<script language="javas cript">
function setfocus()
{
if (document.body. style.cursor="d efault")
{
document.body.s tyle.cursor="wa it";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
else
{
document.body.s tyle.cursor="de fault";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
}
</script>

In my codebehind I have: Me.btnFind.Attr ibutes.Add("onc lick",

"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="w ait") <-- error
if (document.body. style.cursor == "wait") <-- correct, 2 ==

document.body.s tyle.cursor = (document.body. style.cursor =="wait") ? "auto"
: "wait";
document.forms["Form1"].txtPartno.focu s();
document.forms["Form1"].txtPartno.sele ct();

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.n et> wrote in message
news:Ow******** ********@TK2MSF TNGP09.phx.gbl. ..
I have the following javascript in my html:
<script language="javas cript">
function setfocus()
{
if (document.body. style.cursor="d efault")
{
document.body.s tyle.cursor="wa it";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
else
{
document.body.s tyle.cursor="de fault";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
}
</script>

In my codebehind I have: Me.btnFind.Attr ibutes.Add("onc lick", "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="setfoc us" />

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="javas cript">
function setfocus()
{
if (document.body. style.cursor == "default")
{

document.body.s tyle.cursor="wa it";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
else
{
document.body.s tyle.cursor="de fault";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
}
</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="setfoc us()"></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...Tha nks!

Here's what I have tried.

1. I started with using an ASP.NET button control with :
Me.btnFind.Attr ibutes.Add("onc lick","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="javas cript">
function hglass(eventobj ,obj)
{
if (document.body. style.cursor="d efault")
{

document.body.s tyle.cursor="wa it";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();

}
else
{
document.body.s tyle.cursor="de fault";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
}
</script>
The code works, but after one or two finds...IE blows up and crashes.

I tried using cursor=="defaul t" 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.n et> wrote in message
news:OU******** ******@TK2MSFTN GP09.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.cu rsor="wait";
in lieu of
document.body.s tyle.cursor="wa it";

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******** ******@TK2MSFTN GP09.phx.gbl...
Try renaming the function to something other than setfocus(). You could

be
dealing with a reserved word here.

"m miller" <mm*****@epix.n et> wrote in message
news:Ow******** ********@TK2MSF TNGP09.phx.gbl. ..
I have the following javascript in my html:
<script language="javas cript">
function setfocus()
{
if (document.body. style.cursor="d efault")
{
document.body.s tyle.cursor="wa it";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
else
{
document.body.s tyle.cursor="de fault";
document.Form1. txtPartno.focus ();
document.Form1. txtPartno.selec t();
}
}
</script>

In my codebehind I have: Me.btnFind.Attr ibutes.Add("onc lick",

"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=serv er" 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=="defaul t" 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.m icrosoft.com> wrote in message
news:OC******** ******@cpmsftng xa07.phx.gbl...
Hi m miller,

Thanks for your reply. Please try out the following step:
1. remove the "runat=serv er" 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=="defaul t" 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>CursorTe st</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<script language="javas cript">
function ChangeCursor()
{
//alert(document. body.style.curs or)

if (document.body. style.cursor == "wait")
{
document.body.s tyle.cursor="de fault";
document.Form1. txt2.focus();

}
else
{
document.body.s tyle.cursor="wa it";
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="ËÎÌå"><IN PUT 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(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here

btnServer.Attri butes.Add("oncl ick","ChangeCur sor()");
}
private void btnServer_Click (object sender, System.EventArg s e)
{
System.Threadin g.Thread.Sleep( 1000*10);
Response.Write( "<br>Server Button is clicked at:"+
DateTime.Now.To LongTimeString( ));
}

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.Threadi ng.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

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

Similar topics

1
1724
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 one screen, but this is a PITA when an order has a lot of items as it results in a lot of server-trips as well as scroling. Everything is written...
7
2615
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 href=\"javascript:LaunchApp('$command')\">blah</a></td>"; This works fine. But when 'mySubDir' becomes 'my Sub Dir' myapp requires quotes: myapp.exe -P "d:\mydir\my Sub Dir"
16
2677
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. I'd appreciate it if people here had a look at my page on the experiment, and tell me if they see any methodological flaws, before I go and...
6
5122
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 first I thought it may be a permission problem as far as writing the .ldb file to disk, but I added every single user and gave them write permissions...
8
1534
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 are two things I need to get rid of though. One, this code keeps the calling window open (i.e., when you click on the URL, a new IE window...
14
5430
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 that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I...
1
1969
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 everything is ok. BUT, the problem is when a user closes the childwindow using the x before redirect has activatet from the childwindow. Then the...
2
1392
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 normal image links to go back and forward through it. What I want to do: I want an image link that closes the window when clicked, so people can go...
2
1963
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 clean up the database when the user exits before actually logging out. I was told to user pageX, but does not seem to work either. Again, I am...
7
1352
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 now comes when the user has to be marked as logged out. How can I solve the problem that when the browser closes unexpectedly that it then carries out...
0
7459
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...
0
7393
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...
0
7653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7803
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...
1
7411
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...
0
7749
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...
0
5965
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...
0
3444
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...
1
1871
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.