Go Premium for a chance to win a PS4. Enter to Win


Problems with AJAX on WINCE and IE 4.01

Posted on 2009-04-05
Medium Priority
Last Modified: 2012-05-06

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,
Question by:gandalf97
  • 5
  • 4
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24076885
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

Author Comment

ID: 24077460
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

LVL 75

Accepted Solution

Michel Plungjan earned 1500 total points
ID: 24077620
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

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 24077985
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.


Author Comment

ID: 24078010

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?

LVL 75

Expert Comment

by:Michel Plungjan
ID: 24078400
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

Author Comment

ID: 24080569
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?

LVL 75

Expert Comment

by:Michel Plungjan
ID: 24080616
Sorry, no. last time I used IE4 was like a few years before the change of the millennium

Author Closing Comment

ID: 31566841
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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A brand new malware strain was recently discovered by security researchers at Palo Alto Networks dubbed “AceDeceiver.” This new strain of iOS malware can successfully infect non-jailbroken devices and jailbroken devices alike.
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

876 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