Friday, January 30, 2009

What is ajaxTweaks.js in Relate+?

I got a question the other day about the ajaxTweaks.js file that is included in the Relate+ template package, located in /Templates/RelatePlus/JavaScripts. The actual question was; what is it and why do we include it? Even though the answer is pretty straight forward, I’m going to elaborate a bit.

Pretty early on in the process of developing the templates we decided to include some Ajax features. We didn’t want to overdo the Ajax implementations and we wanted to give the developers an easy way out if they decided to skip the use of Ajax. For these reasons, among others, we decided to go with Microsoft ASP.NET AJAX together with ASP.NET AJAX Control Toolkit.

As soon as you introduce AJAX and more advanced JavaScript you are more likely to run into compatibility issues with different browsers, which we indeed did. Of course this is dependent on which browsers you want to support. We first noted that we had a problem with our modal pop-ups in the newly-out-of-beta Chrome. As we suspected we got the same issues with Safari 3, since both browsers are using new versions of WebKit as browser engine.

The problem appeared similar to what follows:

   1: Sys.ScriptLoadFailedException: The script 'http://localhost:2241/WebResource.axd?d=hvpXhV5kEMwLgAoaIglURevR_XTtDTBoKZ3aZWWaIvEkBXbLudri1AIv5bRs5f6licjCZMs3Z3MioQLqLTXV98582pKDHkD7BucGkKsPLz41&t=633444640020014740' failed to load. 
   2: Check for: Inaccessible path. 
   3: Script errors. (IE) Enable 'Display a notification about every script error' under advanced settings. 
   4: Missing call to Sys.Application.notifyScriptLoaded()
Apparently Microsoft AJAX doesn’t recognize Chrome and Safari 3 as browsers using WebKit, therefore they will be treated as unsupported browsers. This is due to the version number of WebKit. With that said we need a way to “tell” Microsoft AJAX that these browsers are in fact supported – in comes ajaxTweaks.js!What ajaxTweaks.js actually does is to add new browser detection code to recognize any browser with WebKit in its user-agent as a Webkit browser, independent of the version of WebKit. To enable the ajaxTweaks to be run, we put a reference to the ajaxTweaks.js file in our MasterPages.

Microsoft will hopefully address this limitation in the near future, but until then we just have to use the ajaxTweaks.js!

For more information see: http://forums.asp.net/t/1252014.aspx

4 comments:

Anonymous said...

does the error below on the Members page ring any bells. using IE7
"XML tag name mismatch (expected meta) createCallback()("")ScriptRe...=66d72566 (line 5) Members.aspx?_TSM_HiddenField_=ctl00_RelateScriptManager_HiddenField&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d3.0.20229.20843%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aen%3a3b7d1b28-161f-426a-ab77-b345f2c428f5%3ae2e86ef9%3a1df13a87%3a8ccd9c1b()()"

Anonymous said...

I've got to the bottom of this. In the relate+ package calls such as

type="text/javascript" src=http://download.skype.com/share/skypebuttons/js/skypeCheck.js

AND http://mystatus.skype.com/smallicon/

will not function correctly with strict firewall rules..

Tom Stenius said...

Hi Anonymous,
The integration with Skype in the Relate+ template package has to call javascripts and images at Skype domain to enable the integration, that is showing the Skype online status of a user.

Either you have to open your firewall to enable the integration, or you could simply remove the Skype integration.

Best regards,
Tom Stenius

Tom Stenius said...

Hi Anonymous,
Sorry to say that I have not seen the error you are talking about. Is it a out-of-the-box installation?

Best regards,
Tom Stenius