Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
guidelines:javascript_compatibility [2021/04/26 08:16]
0.0.0.0 creado
guidelines:javascript_compatibility [2021/06/09 10:52] (actual)
Línea 1: Línea 1:
 ====== Guidelines:JavaScript_Compatibility ====== ====== Guidelines:JavaScript_Compatibility ======
 +{{indexmenu_n>6}}
  
 It's important to maintain Javascript cross browser compatibility. In order to do this, please respect the following tips. It's important to maintain Javascript cross browser compatibility. In order to do this, please respect the following tips.
  
-====== General tips ======+===== General tips =====
 It's important to define **the scope of variables**.  It's important to define **the scope of variables**. 
   * If you want to create a local variable inside a function then use //var// statement at declaration time. For example:   * If you want to create a local variable inside a function then use //var// statement at declaration time. For example:
  
 +<code>
  function some_function() {  function some_function() {
   var parent = value[['parent']];   var parent = value[['parent']];
Línea 13: Línea 15:
   .   .
   .   .
 +</code>
  
   * If you want to create a global variable then use //var// statement outside a function in declaration time. For example:   * If you want to create a global variable then use //var// statement outside a function in declaration time. For example:
  
 +<code>
  document.ready( function{  document.ready( function{
   var global_counter;   var global_counter;
Línea 21: Línea 25:
   .   .
   .   .
 +</code>
  
-====== Jquery UI 1.7 ======+===== Jquery UI 1.7 =====
 First, if you use the current stable version of Jquery you should not have any problems. First, if you use the current stable version of Jquery you should not have any problems.
 If you want to use the **Jquery 1.7 drag and drop functionality with IE9** you have to change HTML headers in order to use the IE7 render mode. If you want to use the **Jquery 1.7 drag and drop functionality with IE9** you have to change HTML headers in order to use the IE7 render mode.
 To render with IE7 mode comment the HTML statement <!DOCTYPE... of the HTML header: To render with IE7 mode comment the HTML statement <!DOCTYPE... of the HTML header:
  
- +  echo '<\!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--\>'."\n";
- echo '<\!--<!DOCTYPE html PUBLIC "-<nowiki>//</nowiki>W3C<nowiki>//</nowiki>DTD XHTML 1.0 Transitional<nowiki>//</nowiki>EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--\>'."\n";+
  
 and set the meta tag compatibility with IE7: and set the meta tag compatibility with IE7:
  
- +  echo '<meta http-equiv="X-UA-Compatible" content="IE=7" >' . "\n";
- echo '<meta http-equiv="X-UA-Compatible" content="IE=7" >' . "\n"; +
    
 You have an example in Pandora FMS index.php page (we use drag & drop in visual console editor and preview): You have an example in Pandora FMS index.php page (we use drag & drop in visual console editor and preview):
  
- +<code> 
- . +
- . +
- . +
- ?>  +?>  
- <?php  +<?php  
- <nowiki>//</nowiki> Render with IE7 mode in visual console editor and preview (due to jquery drag and drop functionality doesn't work in IE9) +// Render with IE7 mode in visual console editor and preview (due to jquery drag and drop functionality doesn't work in IE9) 
- if (($sec2 == 'godmode/reporting/visual_console_builder' and $tab_vc == 'editor') or ($sec2 == 'operation/visual_console/render_view')) { +if (($sec2 == 'godmode/reporting/visual_console_builder' and $tab_vc == 'editor') or ($sec2 == 'operation/visual_console/render_view')) { 
-    echo '<\!--<!DOCTYPE html PUBLIC "-<nowiki>//</nowiki>W3C<nowiki>//</nowiki>DTD XHTML 1.0 Transitional<nowiki>//</nowiki>EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--\>'."\n"; +   echo '<\!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--\>'."\n"; 
-    echo '<meta http-equiv="X-UA-Compatible" content="IE=7" >' . "\n"; +   echo '<meta http-equiv="X-UA-Compatible" content="IE=7" >' . "\n"; 
- } +
- else { +else { 
-    echo '<!DOCTYPE html PUBLIC "-<nowiki>//</nowiki>W3C<nowiki>//</nowiki>DTD XHTML 1.0 Transitional<nowiki>//</nowiki>EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"; +   echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"; 
-    echo '<meta http-equiv="X-UA-Compatible" content="IE=9" >' . "\n"; +   echo '<meta http-equiv="X-UA-Compatible" content="IE=9" >' . "\n"; 
- } +
- echo '<html xmlns="http://www.w3.org/1999/xhtml">'."\n"; +echo '<html xmlns="http://www.w3.org/1999/xhtml">'."\n"; 
- ?> +?> 
- <![[endif]]--> +<![endif]--> 
- . +
- . +
- . +
- +</code>
-[[Category:Guidelines]]+
ºº