0

I have seen many topics with similar portions of this issue but I have yet to find a solution to my exact problem. I have a website developed in Visual Studio Express 2013 for Web. It includes some jQuery 2.2.2 scripts to determine filesize values of selected files. Here is the jQuery:

    $(function() {
    $('#MiscUpload').change(function () {
        if (this.files[0] != null)
        {
        var f = this.files[0]
        if ((f.size || f.fileSize)     > 4096000) {
            $('#UploadSizeLbl').empty()
            $('#UploadSizeLbl').append("File Size: " + ((f.size || f.fileSize) / (1024 * 1024)).toFixed(1) + " MB. Cannot exceed 4 MB. Please reply to your confirmation e-mail with the file or p drive location.")
            $('#UploadSizeLbl').css('color', 'red')
            $('#UploadSizeTxt').val(null)
            $('#MiscUpload').val(null)

        } else {
            $('#UploadSizeLbl').empty()
            $('#UploadSizeLbl').append("File Size: " + ((f.size || f.fileSize) / (1024 * 1024)).toFixed(1) + " MB")
            $('#UploadSizeLbl').css('color', 'green')
            $('#UploadSizeTxt').val((f.size || f.fileSize))
        }}
    })
})

This runs perfectly on the local machine in IE11. When deployed from a web server (2012 R2) with IIS version 8.5, the jQuery does not fire in IE 10 or 11, with compatibility mode on or off. It is not specific to this code, there are other .change and .click functions and none of it works in IE. When I run the site in Chrome, everything runs perfectly. IE can execute the code properly, because it works fine when ran locally instead of from IIS. There are no errors, it simply doesn't fire.

I have tried setting X-UA-Compatibility to IE=Edge, also tried IE8 and EmulateIE8 at the IIS level.

How can I get my jQuery to fire in IE from IIS?

EDIT: This is still not working. The server is in Security Zone "Local Intranet". Users by default have "View Intranet Sites in Compatibility Mode" checked. When they are view in Compat. mode the jQuery does not fire. If they uncheck that box the jQuery WILL fire. If they recheck that box, the jQuery will STILL fire.

A Williams
  • 11
  • 2
  • Is other (non-jQuery) JavaScript working? The problem may be that the IE security zone that the server is in is configured to disable JavaScript. See if the server and localhost are in the same security zone. – Tony Hinkle Jun 28 '16 at 15:24
  • @TonyHinkle Can you help me with the best way to check the security zones? I'm familiar with security settings in IE, but I'm not positive on how it is that I perform this kind of check. – A Williams Jun 28 '16 at 15:46
  • @TonyHinkle Is this 'Internet', 'intranet', 'trusted sites', and 'restricted sites' in IE? I added the webserver to 'Trusted Sites' and I think it's working now... – A Williams Jun 28 '16 at 15:51
  • Yes, that's what I was referring to. – Tony Hinkle Jun 28 '16 at 16:31

1 Answers1

0

The server is in a different security zone that has JavaScript disabled. Add the server's host name or domain to a zone that allows JavaScript (such as the trusted domain), or enable JavaScript on the zone it is in.

To see what zone a website is in, navigate to the site and select File->Properties from the IE menu, where the site's zone is displayed.

Tony Hinkle
  • 4,706
  • 7
  • 23
  • 35
  • Thank you. I added the web server to 'Trusted Sites' and tried again and the jQuery did fire. However, I did the same for IE11 for two other users in my department. It did not fire on either of their machines. Perplexing! After that, I reset my security to default and removed the server from 'Trusted Sites' and the jQuery *still* fires for me now. I'm at a loss. – A Williams Jun 28 '16 at 17:43
  • I don't think JavaScript is disabled by default (except perhaps on restricted sites), so I would expect that it would work after setting yours back to default. When it doesn't work, check the "active scripting" setting on the zone's options, which can be seen by clicking the "Custom Level" button on the Security tab of the IE Options dialog. – Tony Hinkle Jun 28 '16 at 18:12
  • Also, hit F12 and see if the browser is reporting any errors when attempting to download jQuery. – Tony Hinkle Jun 28 '16 at 18:13
  • Oh yes, I should add the Security Zone for the site is 'Local Intranet' on all of the machines, but I suspected maybe I had something extra on mine. I did check that "active scripting" was enabled on the other users machines. I can't fathom why it didn't work on my machine, then after some finagling it finally did, then when resetting security to default it continues to work. Nor can I seem to replicate my settings to other users and get it to work for them. – A Williams Jun 28 '16 at 18:18
  • Users have automatic compatibility setting for intranet sites (which this is). If I have them uncheck that box, the jQuery will fire for them. However, there are thousands of internal users for this app, so I cannot have everyone uncheck that box. I set the Compatibility to IE=Edge at the IIS level, but that doesn't seem to be curing the issue. Any ideas? – A Williams Jun 28 '16 at 20:40
  • When you say, "at the IIS level," do you mean you added `` in page header? – Tony Hinkle Jun 28 '16 at 20:43
  • Lots of caveats listed in answers and comments at http://stackoverflow.com/questions/3449286/force-ie-compatibility-mode-off-using-tags, so you'll need to go everything there... – Tony Hinkle Jun 28 '16 at 20:45
  • Yes, except I am not using a meta tag to declare it in the actual HTML of the site, but instead declaring it for the entire app within the IIS setting. There is a "HTTP Response Header" section of the actual IIS UI where you can define headers. I also tried adding it into the web.config file as some users there are suggesting. – A Williams Jun 28 '16 at 21:06