Solved

Onchange Causes Blank Frame in IE6

Posted on 2004-09-08
7
361 Views
Last Modified: 2008-02-07
I am experiencing odd behavior with Internet Explorer 6 (exact version = 6.0.2900.2180.xpsp_sp2_rtm.040803-2158).
The basic problem is that a frame becomes blank when the following events occur:

1. The user submits a form that has a significant delay (>3 seconds)
2. On the same frame as the submitted form is a select (drop-down) with an onchange handler that also goes to the server
3. While waiting for the submit to return, the user clicks on the select so that its list is displayed (but does not actually click on an item)
4. When the submit returns (provided the drop-down list is still displayed), an onchage event is fired (even though the user never actually clicked on an item)
5. The onchage handler makes another request on the server, the server returns the correct page, but it is not displayed - the frame goes blank

Interestingly, this problem does not occur when the frame page is the top frame or with IE5.5 or Netscape. Here is some code to reproduce it:

The overall frameset (index.html):
======================
<html>

<frameset rows="120,*">
  <frame src="header1.html" name="header">
  <frame src="main.html" name="main">
</frameset>

</html>

The Main Page (main.html):
==================
<html>
<head>
<script>
function processOnchange() {
  window.location.href ="onchange.html";
}
</script>
</head>
<body>
<form name="form1" action="DelayServlet" method="post">
<select name="select1" onchange="processOnchange()">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>
<input type="submit" value="Submit">
</form>
</body>
</html>

The Header Page (header1.html):
=====================
<html>
<body>
<h1>Header</h1>
</body>
</html>

The Onchange Page (onchange.html):
=======================
<html>
<body>
<h1>Onchange Page</h1>
</body>
</html>

DelayServlet (doesn't have to be a Servlet, just something that causes a delay and returns the same page):
====================================================================
public class DelayServlet extends HttpServlet {
 
  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    try {
      Thread.currentThread().wait(3000);
    }
    catch(InterruptedException e) {
      e.printStackTrace();
    }
    RequestDispatcher rd = req.getRequestDispatcher("main.html");
    rd.forward(req, resp);
  }
}

Hopefully if I've cut and pasted everything correctly, the problem will be demonstrated by loading index.html and following the steps at the beginning of this question. Also as previously noted, if you just load main.html and follow the same steps there is no onchange event and no problem.

Marc
0
Comment
Question by:marc_rabil
  • 4
  • 2
7 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 250 total points
ID: 12006516
How about bllocking onchange when submitted:

<html>
<head>
<script>
var submitted = false;
function processOnchange() {
  if(submitted==false){
    window.location.href ="onchange.html";
  }
}
</script>
</head>
<body>
<form name="form1" action="DelayServlet" method="post" onSubmit="submitted=true">
<select name="select1" onchange="processOnchange()">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
<option value="5">Option 5</option>
</select>
<input type="submit" value="Submit">
</form>
</body>
</html>

0
 
LVL 33

Expert Comment

by:knightEknight
ID: 12006530
you can try making the onchange conditional on whether the form is submitting:

var submitting = false;

function processOnchange() {
  if ( !submitting )
     window.location.href ="onchange.html";
}
</script>
</head>
<body onload="submitting=false;" >
<form name="form1" action="DelayServlet" method="post" onsubmit="return submitting=true;" >
<select name="select1" onchange="processOnchange()">
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 12006535
great minds think alike!
(and so do ours)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 63

Expert Comment

by:Zvonko
ID: 12006549
;-)
0
 

Author Comment

by:marc_rabil
ID: 12006698
Thanks guys.  I forgot to mention that I already have figured out this solution.  Unfortunately, the real world application has many dynamically generated forms and scripts and ensuring this flag always gets set is going to be a fair amount of work.

If its the only way, I guess that's what I'll have to do, but I was hoping you experts would know what the underlying problem is.

Marc
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 12006864
Sorry, but I have not encountered such behaviour.
Also I cannot imagine that it works that way.
My understanding is that onchange tries to change the location even when the response is not back from last submit.
The fact the the new location request is not seen in Netscape or older IEs does only say that onchange did not fire correctly.

If you claim that onchange never has to be fired because the user did not select an option, then you are true (but looking is perhaps half selecting ;-)

I can tell you a story were we got ominous server crashes only from a testing location. All other location worked correctly with that page and server.
The differece was that those testing group used a slow ISDN router and has also the bad bahaviour to select the options by cursor keys (not by mouse)
So now in that server version was not a buffer overrun protection for long requests url.
So the onchange of the select with fifty options fired longer and longer action urls while they scrolled down the options list with the cursor!
After 2048 bytes the server buffer overflow occured.


0
 
LVL 63

Expert Comment

by:Zvonko
ID: 12006879
Or was it 4096 bytes, I do not remember.
But the solution was to change the action concatination to parameter replacement until the server was upgraded.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now