Problems with AJAX on WINCE and IE 4.01


I have a web page that contains several user defined controls inside an update panel.  When one of them is updated and a TAB is pressed, a postback is automatically generated.  Code on the server side is supposed to populate several textboxes if the data item is found and then set the focus to a specific textbox on the form (inside the update panel).  In most browsers this worked as expected.  However, the ultimate target is a barcode scanner based on a PocketPC and no matter what I do, I can't seem to get it to return from the postback and have the focus in the field where I set it.  

The OS is WinCE and the browser identifies itself as IE 4.01.  The browser capabilities indicate that Javascript is supported.  Placing a <noscript> tag on the form does not have the javascript code inside run but then I am having problems getting other script to run on that device.  Unless I am mistaken, Javascript *should* be supported and enabled on this device.

I have tried adding javascript event handlers for before and after postback to the form.  In my test, I just fire alerts indicating which handler has been called.  Both fire just fine when I test from desktop machines running IE 6.  Again, when I run from the scanner I don't get anything.

I cannot just mandate the client update the barcode scanner.  I need something that will help me code around this problem and QUICKLY as I am in a severe time crunch on this one.  I really need an answer by Noon Eastern U.S. time on Monday.

Thanks in Advance,
Who is Participating?
Michel PlungjanConnect With a Mentor IT ExpertCommented:
this COULD have told you

// Provide the XMLHttpRequest class for IE 5.x-6.x:
if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() {
  try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
  throw new Error( "This browser does not support XMLHttpRequest." )

except IE4 does not support try/catch either


looks to me like an embedded activeX object

You might also want to add
if (document.all &&!document.getElementById) document.getElementById = function(id) { return document.all(id) }

to the top of the page
Michel PlungjanIT ExpertCommented:
ermm. Did you just write that script placed inside noscript tags did not run???
If it did it would be fairly miraculous.

Anyway, can you post the code you are trying to execute?

If it uses xmlhttp, I am pretty sure it is not supported in IE4
Iframes are supported so perhaps you would want to try to post to hidden iframes
gandalf97Author Commented:
LOL...  I meant that the *text* I put in the noscript tag didn't show up which leads me to believe that Javascript is enabled.  I am also getting an alert to fire each time the page loads, including after postback.

I did include some script in the code window.  I'm trying to move things around and see if putting the script in the <head> will make any difference.  It's been a year since my job focused on Javascript and I am rusty on the finer points.

Are you saying that IE4 doesn't support AJAX at all?  So what is going on with the pages?  How is the markup being generated when the page is posted back?  Can you send me a pointer to something that talks about AJAX being supported or not on IE4?

Thanks for posting.  I do have a small extension of a couple of hours but this is still time sensitive.


<head id="Head1" runat="server">
    <title>Inventory Withdrawl</title>
    <script type="text/javascript">
      alert("Page being loaded."); //20090406 Msg prints out on every page load on all devices.
          function pageLoad() {
 	    //20090403 1619.  Msg prints out *every* time the page loads, including after postback. (IE6)
 	    //20090406 0921.  Msg does NOT print out AT ALL on Symbol. (IE 4.01)
 	    alert("Page should be loaded.");
Additional Script:  (This is all in the body)
    <script type="text/javascript">
 	  //alert("Stuff Should be loaded");
 	  var oHiddenDiv
 	  var oParent
 	  var oTarget
 	  oHidNextFocus = document.getElementById("hidNextFocus");
 	  //foo = oHiddenDiv.InnerText;
 	  //oParent = 
 	  oTarget = document.getElementById(oHidNextFocus.value);
 	  //oTarget = document.getElementById("");
 	  //foo.value = "ssss";
//20090406 0952 Commented out pageLoad here and moved it to the head.
// 	  function pageLoad() {
 	    //20090403 1619.  Msg prints out *every* time the page loads, including after postback.
 	    //20090406 0921.  Msg does NOT print out AT ALL on Symbol.
// 	    alert("Page should be loaded.");
// 	  }
 	  var prm = Sys.WebForms.PageRequestManager.getInstance();
      function BeginRequestHandler(sender, args) {
        // This code is executed before an async. postback
        alert("before postback");
      function EndRequestHandler(sender, args) {
        // This code is executed after a successful async. postback 
        alert("after successful postback");
        oTarget = document.getElementById(oHidNextFocus.value);
      //20090406 EAS - Below line only prints when page first loaded and before msg from pageLoad()
      alert("This should print no matter what.");

Open in new window

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

gandalf97Author Commented:
Thanks for the quick response!

Thanks for the pointer to the Wiki article.  That will help me with the conversation I will need to have with my boss.  I need to be able to show her things like that.

I am working with ASP.NET (VB) 2.0 and the MS AJAX toolkit.  The AJAX piece is so I can do partial postbacks and only update a couple of controls on the screen.  This all seems to work the way I expect it to on the desktop (IE 6) but not the barcode scanner (IE4).  So, I am not sure of the mechanics but when the barcode scanner scans a work order, the WO is looked up and fields are populated just like on the desktop.  I can't say whether AJAX was ignored and the whole thing reloaded or not.  It is hard for me to tell.  I just know that it seems that some script is running and some is being ignored.

I will try adding that if(document.all....) code.  Should I add it near that alert in the head?  What is it supposed to do?

At this point, I will be happy if after a postback I can detect the browser and get a piece of javascript to run that sets focus to the part# text box.  Once I can get the alert to fire after postback, I know how to code setting the focus.

Thanks again.

gandalf97Author Commented:

I pasted: if (document.all &&!document.getElementById) document.getElementById = function(id) { return document.all(id) }

into my code.  It doesn't appear to do anything when I paste it right after the first alert.  Do I need to move it?

Michel PlungjanIT ExpertCommented:
It implements the getElementById for IE4 if it does not exist. I it does not exist, then none of your code would work even with ok postback
It can be pasted anywhere, but right after the openeing script tag is a good place
gandalf97Author Commented:
Ok.  Thanks.  I put it in and it doesn't seem to make a difference.  I am still just getting the "page being loaded" alert when the page first loads and after the postback.  (On the IE4 machine).

Any further suggestions?

Michel PlungjanIT ExpertCommented:
Sorry, no. last time I used IE4 was like a few years before the change of the millennium
gandalf97Author Commented:
I still have trouble accepting that IE4 on a mobile device doesn't support what I was trying to do.  However, this was helpful in moving me down the road to an answer and I appreciate the help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.