2

I am working on an ASP.NET application that includes JavaScript to dynamically enable or disable validators on the page. In ASP.NET there is a web resource that is provided with the app that includes JavaScript functions for this purpose, such as ValidatorEnable(). When I run our application on Safari on a Mac, I am getting the error that it cannot find ValidatorEnable. This is a function we are calling in the jQuery(document).ready() callback function, so the expectation is that all resources are available at this point. Inspecting in the debugger reveals that the resource was never delivered to the client browser.

Has anyone seen something like this before? This problem does not occur on IE, Chrome, or Firefox on Windows, nor does it occur on Chrome or Firefox on the Mac. Safari seems to be the one that is not correctly receiving or processing the ASP.NET JavaScript validator functions.

Thanks in advance!

David Whiteman
  • 110
  • 1
  • 10

1 Answers1

5

I've posted a blog post regarding the browser identification function for ASP.NET 2.0. Basically, there is a collision in the browser version string for chrome starting in 7.1. Asp.Net believes that you are running an older version of Safari Browser that doesn't support recent javascript. By changing the <browserCaps> element of your web.config, you can match the newer version and assign the correct capabilities.

<configuration>   
  <system.web>     
    <browserCaps>       
      <filter>
        <case match="AppleWebKit/600">EcmaScriptVersion = 1.5           
          supportsCallback = true         
        </case>       
        <case match="AppleWebKit/601">EcmaScriptVersion = 1.5           
          supportsCallback = true         
        </case>       
        <case match="AppleWebKit/602">EcmaScriptVersion = 1.5           
          supportsCallback = true         
        </case>    
        <!-- Speculative futureproofing could do this?               
        <case match="AppleWebKit/603">EcmaScriptVersion = 1.5           
          supportsCallback = true         
        </case>       
        <case match="AppleWebKit/610">EcmaScriptVersion = 1.5           
          supportsCallback = true         
        </case>       
        <case match="AppleWebKit/650">EcmaScriptVersion = 1.5           
          supportsCallback = true         
        </case>       
        -->
      </filter>     
    </browserCaps>   
  </system.web>
</configuration>

There are other methods of fixing it.

Community
  • 1
  • 1
DrewDouglas
  • 493
  • 4
  • 9
  • Thanks, Drew. If my web.config does not have a element within , is that expected? Does adding this just extend/correct the built-in browser detection? – David Whiteman Oct 15 '14 at 21:26
  • @DavidWhiteman You can just add the element. It depends on the implementation whether or not this is present in the web.config file. To my knowledge, it is not included when creating a new Web.Config via Visual Studio. Depending on which framework you're working on the authors may or may not have added it for their base Web.Config. – DrewDouglas Nov 10 '14 at 20:11
  • Heads-up: this doesn't work with iOS 9 where Safari now identifies as "AppleWebKit/601". – Dai Jan 22 '16 at 07:50
  • For the iPhone 6s you need this: EcmaScriptVersion = 1.5 supportsCallback = true – Kosta Feb 06 '16 at 18:37
  • is needed for iOS 10 – Tal Aloni Dec 22 '16 at 13:43
  • Safari 10.1 (Running on OS X 10.12.4) was released on March 27, 2017. Updates require AppleWebKit/603. – atjoedonahue Apr 24 '17 at 20:09