ReferenceError: Can't find variable: ValidatorEnable in Safari

跟風遠走 提交于 2020-01-04 15:16:49

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/26224314/referenceerror-cant-find-variable-validatorenable-in-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!