Tuesday, December 27, 2011

Javascript Error - IE Stop Running This Script



Most often web developer experiencing “stop running this script? “  error in IE browser, especially in IE7 and IE6. This script error is triggered by following causes which is not focused by programmer while handling large volume of page content (DOMs).
Causes:

  1.  Javascript looping the operation in infinite time or more than threshold. (or)
  2. Javascript read/write DOM in many times. (or)
  3.  Mulitple ajax request at the same time. (or)
  4.  Synchronous ajax. (or)
  5.  Deadlock in called function.
Sollution:
1)      Go through your code and just use try and catch inside loop. Better to define termination of loop on exception.
2)      Please limit loop with few number of iteration (Normally iteration in 100s would be better).
3)      Minimise searching object within DOM. Here jQuery developers have to focus the area selector.
A)     Avoid global Selector. [ $(“*”) ]
B)      Avoid global find operation. For example, use $(“div#myID”).find() instead of $(“body”).
C)      Minimize the Selector function call. For example use copy of selected object instead of using selector. For more clearance see following piece of code


4)      Use Asynchronous ajax by setting the property “async: true” in $.ajax({}).
5)      Threading script flow by using setTimeout() (or) setInterval(). Let’s take above code snippet. Let’s assume css() function is independent of its following line. And css() doesn’t return any value and  it’s output is not required by subsequent lines, means call css() function with setTimeout as follows,

6)      Avoid duplication of event handler. These kind of duplication is occurred existence of same code in single js file or different js files. For example doubled existing of the code following code will give two alert box for single click.

Note: Please leave your queries and suggestion as comment.

Sunday, July 24, 2011

drupal_add_css is not working

Drupal remove css file starts with base path. For example, if you are trying to add  css like drupal_add_css(base_path().drupal_get_path('module','your_module').'css/mystyle.css'), then base_path() function is make your css file unreadable.

To fix this remove base_path() function from drupal_add_css and you should say drupal as follows drupal_add_css(drupal_get_path('module','your_module').'css/mystyle.css'). The css path string should look like /sites/all/modules/your_module/css/mystyle.css instead of /your_project /sites/all/modules/your_module/css/mystyle.css.

Drupal 7 provide more flexible options data will allow you to change path. For more detail go to http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_add_css

Note: Please leave your queries and suggestion as comment.

Thursday, July 21, 2011

Fatal error: Call to undefined method HTML2FPDF::DisplayPreferences()

Fatal error: Call to undefined method HTML2FPDF::DisplayPreferences() in C:\External Program Files\xampp\htdocs\projectname\sites\all\modules\yourmodule\html2pdf\html2fpdf.php on line 158

This error is rising because of path problem.To resolve this error, define constant named RELATIVE_PATH as following