Igor Kitsula - Developer

A Programmer Reference


SyntaxHighlighter 3.0.83 after AJAX call "Can't find brush for: BRUSH" fix

After implementing pagination on my website, I was not able to highlight the code with SyntaxHighliter plugin. After AJAX call script was throwing an error: "Can't find brush for: BRUSH". After little research I found reported bug and temporary solution...

This fix is works for me and I think it can be helpful to share with others this experience. I made this fix in plugin source code, combine shCore.js, shAutoloader.js and XRegExp.js files into one, minify and compress it with YUICompressor.

Read more...

MVC Handling and logging JavaScript errors

Most of browsers have window.onerror event which fired when JavaScript error occur. You can bind your function to this event which receives three parameters: message, URL and line number where error raised.

Let’s create function which will be graceful handling of JavaScript errors, send in poor JavaScript AJAX request all information about error and then we can log it with Log4Net and send email notice.

Read more...

External links in new window using jQuery

Instead of using each time attribute target="_blank" for hyperlinks you can use jQuery.

$().ready(function () {
    $('a[href^=http]').addClass('external').attr('target', '_blank');

On loaded page jQuery selects all links on the page which begins with 'http', applies class "external" and adds attribute "target=_blank". Example any external link on this webpage. Is it not simple and nice? BTW, Strict HTML don’t allow using target=_blank attribute.

Favicon and robots.txt or What deployment begins from

Before the first deployment of new website you add Google Analytics tracking code on it and want to search engines start to indexing it. Of course you don't want to have any errors on first indexing. My experience shows that one's of important files that search engines trying to get are robots.txt and favicon.ico. First tells robots about possible restrictions, second - just an icon of website (which is shows in address bar of browser).

Read more...