Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

Rate It (1)

Last post 11-03-2009 2:49 PM by BBuzzi. 22 replies.

Sort Posts:

  • Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    04-23-2008, 12:17 PM
    • Member
      2 point Member
    • taliesins
    • Member since 04-14-2008, 2:03 PM
    • Posts 6

    Safari 3 is detected as Sys.Browser.Safari. There are specific hacks for Safari implemented in MicrosoftAjax.js. These hacks cause problems with Safari 3 as it uses a new javascript rendering engine called WebKit.

    The hacks can cause dreaded errors like when updating a control's visibility from false to true in an updatepanel during a partial update. When that occurs it needs to download the supporting javascript to run the now visible server control. With the hacks in place it does not properly dynamically load the javascript file and it throws the following error:

    Sys.ScriptLoadFailedException: The script 'http://localhost:2241/WebResource.axd?d=hvpXhV5kEMwLgAoaIglURevR_XTtDTBoKZ3aZWWaIvEkBXbLudri1AIv5bRs5f6licjCZMs3Z3MioQLqLTXV98582pKDHkD7BucGkKsPLz41&t=633444640020014740' failed to load. Check for:
    Inaccessible path.
    Script errors. (IE) Enable 'Display a notification about every script error' under advanced settings.
    Missing call to Sys.Application.notifyScriptLoaded().
     
    Now WebKit runs MicrosoftAjax.js without any problems. So I have modified the following to detect a new browser type called WebKit.

    In the file called "MicrosoftAjax.debug.en-US.js" (do the same for the other cultures)

    Change:

    Sys.Browser = {};
    Sys.Browser.InternetExplorer = {};
    Sys.Browser.Firefox = {};
    Sys.Browser.Safari = {};
    Sys.Browser.Opera = {};
    Sys.Browser.agent = null;
    Sys.Browser.hasDebuggerStatement = false;
    Sys.Browser.name = navigator.appName;
    Sys.Browser.version = parseFloat(navigator.appVersion);
    if (navigator.userAgent.indexOf(' MSIE ') > -1) {
        Sys.Browser.agent = Sys.Browser.InternetExplorer;
        Sys.Browser.version = parseFloat(navigator.userAgent.match(/MSIE (\d+\.\d+)/)[1]);
        Sys.Browser.hasDebuggerStatement = true;
    }
    else if (navigator.userAgent.indexOf(' Firefox/') > -1) {
        Sys.Browser.agent = Sys.Browser.Firefox;
        Sys.Browser.version = parseFloat(navigator.userAgent.match(/ Firefox\/(\d+\.\d+)/)[1]);
        Sys.Browser.name = 'Firefox';
        Sys.Browser.hasDebuggerStatement = true;
    }
    else if (navigator.userAgent.indexOf(' Safari/') > -1) {
        Sys.Browser.agent = Sys.Browser.Safari;
        Sys.Browser.version = parseFloat(navigator.userAgent.match(/ Safari\/(\d+(\.\d+)?)/)[1]);
        Sys.Browser.name = 'Safari';
    }
    else if (navigator.userAgent.indexOf('Opera/') > -1) {
        Sys.Browser.agent = Sys.Browser.Opera;
    }

    To: 

    Sys.Browser = {};
    Sys.Browser.InternetExplorer = {};
    Sys.Browser.Firefox = {};
    Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
    Sys.Browser.Safari = {};
    Sys.Browser.Opera = {};
    Sys.Browser.agent = null;
    Sys.Browser.hasDebuggerStatement = false;
    Sys.Browser.name = navigator.appName;
    Sys.Browser.version = parseFloat(navigator.appVersion);
    if (navigator.userAgent.indexOf(' MSIE ') > -1) {
        Sys.Browser.agent = Sys.Browser.InternetExplorer;
        Sys.Browser.version = parseFloat(navigator.userAgent.match(/MSIE (\d+\.\d+)/)[1]);
        Sys.Browser.hasDebuggerStatement = true;
    }
    else if (navigator.userAgent.indexOf(' Firefox/') > -1) {
        Sys.Browser.agent = Sys.Browser.Firefox;
        Sys.Browser.version = parseFloat(navigator.userAgent.match(/ Firefox\/(\d+\.\d+)/)[1]);
        Sys.Browser.name = 'Firefox';
        Sys.Browser.hasDebuggerStatement = true;
    }
    else if (navigator.userAgent.indexOf('WebKit/') > -1) {
        Sys.Browser.agent = Sys.Browser.WebKit;
        Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
        Sys.Browser.name = 'WebKit';
    }
    else if (navigator.userAgent.indexOf(' Safari/') > -1) {
        Sys.Browser.agent = Sys.Browser.Safari;
        Sys.Browser.version = parseFloat(navigator.userAgent.match(/ Safari\/(\d+(\.\d+)?)/)[1]);
        Sys.Browser.name = 'Safari';
    }
    else if (navigator.userAgent.indexOf('Opera/') > -1) {
        Sys.Browser.agent = Sys.Browser.Opera;
    }

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    05-30-2008, 1:15 PM
    • Member
      2 point Member
    • kshakir
    • Member since 05-30-2008, 5:02 PM
    • Posts 1

    Thank-you for your post!  I was having the exact Safari 3 problem you mentioned, with ScriptLoadFailedException's during partial updates.

    I used just this snippet in a ScriptReferenced .js, and it fixed the problem for my setup:

    Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
    if( navigator.userAgent.indexOf( 'WebKit/' ) > -1 )
    {
      Sys.Browser.agent = Sys.Browser.WebKit;
      Sys.Browser.version = parseFloat( navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
      Sys.Browser.name = 'WebKit';
    }

    Is there a "more correct" way of removing the Safari hacks, instead of messing with the Sys.Browser object?

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    05-31-2008, 3:13 AM
    • Member
      2 point Member
    • taliesins
    • Member since 04-14-2008, 2:03 PM
    • Posts 6

    The problem is that if we remove the Safari hacks then Safari 2 will stop working with AJAX. I guess it would be possible to go through all the .js files and find where each hack is and add a version check on top of the browser check.

    Safari 3 is just a nice gui on top of WebKit. I like adding WebKit as a browser type as there are a number of other browsers that use WebKit at its core. This allows us to make WebKit specific "optimizations" if necessary and results in it being applied to all WebKit browsers.

    http://trac.webkit.org/wiki/Applications%20using%20WebKit

    Tali :>

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    06-18-2008, 11:59 AM
    • Member
      2 point Member
    • staffordaz
    • Member since 05-22-2007, 10:34 PM
    • Posts 1

    We are noticing the same problems using the ASP.NET 2.0 version of the Microsoft AJAX Library ("version 1.0" ???).

     How can we change this in the built DLL (or override it)?  All of the source code available for the library only includes the CS and JS files.  There are no project files included in the download.

     
    Thank you very much in advance.
     -Arizona

     

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    07-17-2008, 5:33 AM
    • Member
      2 point Member
    • franzkru
    • Member since 08-31-2006, 10:49 PM
    • Posts 1

     

    Hi,

    I'm using system.web.extension and i can rebuild it (there is no source code). So does any of you can rebuild dll with this fix ? Or tell me where can i found source code for this ?

     Thanks in advance,

    Rob

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    08-10-2008, 8:41 AM
    • Member
      22 point Member
    • mehdi_mousavi
    • Member since 02-23-2006, 11:04 AM
    • Posts 7
    Hi, I've got some issues under Safari 3. I've just modified applied the code you've mentioned to the following file. However, the problem (with Panel Refreshing) is still there. "C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\MicrosoftAjaxLibrary\System.Web.Extensions\1.0.61025.0" How am I supposed to apply this patch? How should I compile the changes into a new .dll???? Thanks.
  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    08-11-2008, 8:01 AM
    • Member
      2 point Member
    • taliesins
    • Member since 04-14-2008, 2:03 PM
    • Posts 6

    How to apply patches to MicrosoftAjax.js

    There are 2 possible ways of doing this. You can replace each script reference or you can set a path for all scripts. Note that it is important that the folder structure remains that same. It needs the namespace and version to calculate where the files are. Don't forget there are a couple of different versions. There is live and debug as well as culture specific files.

    The scripts can be found at http://www.asp.net/ajax/downloads/

    Script Reference Method:

        <asp:ScriptManager ID="ScriptManager" runat="server">
    <Scripts>
    <asp:ScriptReference Name="MicrosoftAjax.js" ScriptMode="Auto" Path="/scripts/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.js" />

    </Scripts>
    </asp:ScriptManager>
      
    ScriptPath Method:

    If you use this method you need to get all the scripts in system.web.extensions and copy them
    to ~/{Where you store you javascript files}.

    <asp:ScriptManager ID="ScriptManager" runat="server" ScriptPath="~/{Where you store you javascript files}"/>
      
  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    09-05-2008, 6:27 AM
    • Member
      2 point Member
    • taliesins
    • Member since 04-14-2008, 2:03 PM
    • Posts 6

     This patch will also allow Google Chrome browser to work MS Ajax as it is based on webkit. Google chrome uses webkit and has a compatible user agent, so it is detected as webkit.

     Regards
        Taliesin Big Smile

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    01-28-2009, 11:50 AM
    • Member
      96 point Member
    • danludwig
    • Member since 10-20-2006, 2:12 PM
    • Posts 80

    I've experimented with this bug a lot, and the best temporary solution is the one proposed by kshakir (second post in this thread). Simply create a single JS file with his code and reference it in your site. To work properly, this script should be loaded before any AJAX control scripts. For my applications, I simply reference it as the first script in the ScriptManager, like so:

    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/Scripts/Safari3AjaxHack.js" />
        </Scripts>
    </asp:ScriptManager>

    The file can exist in any folder in your site, but as kshakir says, it should contain this code:

    Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
    if( navigator.userAgent.indexOf( 'WebKit/' ) > -1 )
    {
      Sys.Browser.agent = Sys.Browser.WebKit;
      Sys.Browser.version = parseFloat( navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
      Sys.Browser.name = 'WebKit';
    }

    Microsoft and the AjaxControlToolkit project managers tell me they want to fix this bug in the toolkit, so eventually this hack will (hopefully) no longer be necessary. But in the meantime, this solution solves the problem with AjaxControlToolkit scripts not being loaded properly during partial updates.

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    03-05-2009, 6:55 AM
    • Member
      19 point Member
    • jeff_b
    • Member since 01-04-2007, 9:45 AM
    • Posts 20
    Thanks this worked for me :)
  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    03-20-2009, 5:48 PM
    • Member
      26 point Member
    • BobbyRich
    • Member since 01-29-2007, 12:48 AM
    • Posts 18
    Awesome! This worked for me too. Spent about two days trying to figure this out!
  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    04-21-2009, 4:19 AM
    • Member
      28 point Member
    • gri4
    • Member since 10-04-2007, 2:23 PM
    • Posts 17

    Also got this bug. Guys, thanks for the solution!

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    04-25-2009, 9:05 AM
    • Member
      9 point Member
    • csnaveen31
    • Member since 05-31-2005, 1:29 AM
    • Posts 3

     I am facing lot of problems when i am using AutoCompleteExtender while accessing in google chrome and safari i tried your suggested solution but still its not working for me.

    Please help me its very very urgent to fix this issue as i have a release next week

     

    The i have used is as follows :

     <ajaxToolkit:ToolkitScriptManager runat="server" ID="ScriptManager1" ScriptMode="Release" EnablePageMethods="True" CombineScripts="true">
     <Scripts>
            <asp:ScriptReference Path="~/scripts/webkit.js" />
        </Scripts>
    </ajaxToolkit:ToolkitScriptManager>

    Where ajaxToolkit is the registered prefix for AjaxControlToolkit and the script file webkit.js contains the following code:

    Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
    if( navigator.userAgent.indexOf( 'WebKit/' ) > -1 )
    {
      Sys.Browser.agent = Sys.Browser.WebKit;
      Sys.Browser.agent = Sys.Browser.WebKit;
      Sys.Browser.version = parseFloat( navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
      Sys.Browser.name = 'WebKit';
    }

     

    AutoCompleteExtender code is as follows :

     

    <ajaxToolkit:AutoCompleteExtender id="autoComplete1" runat="server" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" CompletionListItemCssClass="autocomplete_listItem" CompletionListCssClass="autocomplete_completionListElement" UseContextKey="True" ServiceMethod="GetCompletionList" MinimumPrefixLength="1" CompletionSetCount="30" EnableCaching="false" CompletionInterval="500" TargetControlID="companytxt" BehaviorID="AutoCompleteEx">
                <Animations>
                        <OnShow>
                            <Sequence>
                                <%-- Make the completion list transparent and then show it --%>
                                <OpacityAction Opacity="0" />
                                <HideAction Visible="true" />
                               
                                <%--Cache the original size of the completion list the first time
                                    the animation is played and then set it to zero --%>
                                <ScriptAction Script="
                                    // Cache the size and setup the initial size
                                    var behavior = $find('AutoCompleteEx');
                                    if (!behavior._height) {
                                        var target = behavior.get_completionList();
                                        behavior._height = target.offsetHeight - 2;
                                        target.style.height = '0px';
                                    }" />
                               
                                <%-- Expand from 0px to the appropriate size while fading in --%>
                                <Parallel Duration=".4">
                                    <FadeIn />
                                    <Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
                                </Parallel>
                            </Sequence>
                        </OnShow>
                        <OnHide>
                            <%-- Collapse down to 0px and fade out --%>
                            <Parallel Duration=".4">
                                <FadeOut />
                                <Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
                            </Parallel>
                        </OnHide>
                    </Animations>
                </ajaxToolkit:AutoCompleteExtender>

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    04-27-2009, 8:32 AM
    • Member
      18 point Member
    • zarzar
    • Member since 09-18-2007, 8:52 AM
    • Posts 14

     I've been using this hack since today to solve my problem with AJAX CT in G.Chrome & Safari :)

     Thanks !

  • Re: Compatibility patch for WebKit (Safari 3) 3.5.21022.8 MicrosoftAjax.debug.en-US.js

    04-28-2009, 12:09 AM
    • Member
      9 point Member
    • csnaveen31
    • Member since 05-31-2005, 1:29 AM
    • Posts 3

    Hey How come its still not working for me. Which versions of chrome and safari you are using. Please check and tell is there any code errors or anything else i am missing so i can also get it worked out.

     

    Thanks 

     

Page 1 of 2 (23 items) 1 2 Next >