Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JavaScript] Zmiana czcionki w Joomala A+ A A-
Forum PHP.pl > Forum > Przedszkole
fiasko
[JAVASCRIPT] pobierz, plaintext
  1. switchFontSize=function(ckname,val){
  2. Var $E ;
  3. var bd = $E('BODY');
  4. switch (val) {
  5. case 'inc':
  6. if (CurrentFontSize+1 < 7) {
  7. bd.removeClass('fs'+CurrentFontSize);
  8. CurrentFontSize++;
  9. bd.addClass('fs'+CurrentFontSize);
  10. }
  11. break;
  12. case 'dec':
  13. if (CurrentFontSize-1 > 0) {
  14. bd.removeClass('fs'+CurrentFontSize);
  15. CurrentFontSize--;
  16. bd.addClass('fs'+CurrentFontSize);
  17. }
  18. break;
  19. default:
  20. bd.removeClass('fs'+CurrentFontSize);
  21. CurrentFontSize = val;
  22. bd.addClass('fs'+CurrentFontSize);
  23. }
  24. Cookie.set(ckname, CurrentFontSize,{duration:365});
  25. }
  26.  
  27. </script>
[JAVASCRIPT] pobierz, plaintext



Mam problem, bo nie wiem dlaczego mam komunikat o błędzie :

$E is not defined
var bd = $E('BODY');

Całość wygląda tak :
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  5. <meta http-equiv="Content-Language" content="pl">
  6. <link rel="stylesheet" href="style.css" type="text/css" />
  7. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  8. <script language="javascript"type="text/javascript">
  9. //JS script for Joomla template
  10.  
  11.  
  12.  
  13. switchFontSize=function(ckname,val){
  14. //Var $E ;
  15. var bd = $E('BODY');
  16. switch (val) {
  17. case 'inc':
  18. if (CurrentFontSize+1 < 7) {
  19. bd.removeClass('fs'+CurrentFontSize);
  20. CurrentFontSize++;
  21. bd.addClass('fs'+CurrentFontSize);
  22. }
  23. break;
  24. case 'dec':
  25. if (CurrentFontSize-1 > 0) {
  26. bd.removeClass('fs'+CurrentFontSize);
  27. CurrentFontSize--;
  28. bd.addClass('fs'+CurrentFontSize);
  29. }
  30. break;
  31. default:
  32. bd.removeClass('fs'+CurrentFontSize);
  33. CurrentFontSize = val;
  34. bd.addClass('fs'+CurrentFontSize);
  35. }
  36. Cookie.set(ckname, CurrentFontSize,{duration:365});
  37. }
  38.  
  39. </script>
  40. </script>
  41.  
  42. </head>
  43. <BODY id="bd" class="fs3 FF" bgcolor="#0068D8">
  44.  
  45. <ul class="ja-usertools-font">
  46. <li>
  47.  
  48.  
  49.  
  50. <img id="ja-tool-increase" onclick="switchFontSize('ja_purity_ja_font','inc'); return false;" alt="Zwiększ rozmiar czcionki" src="user-increase.png" title="Zwiększ rozmiar czcionki" style="cursor: pointer;">
  51. </li>
  52. <li>
  53. <img id="ja-tool-reset" onclick="switchFontSize('ja_purity_ja_font',3); return false;" alt="Domyślny rozmiar czcionki" src="user-reset.png" title="Domyślny rozmiar czcionki" style="cursor: pointer;">
  54. </li>
  55. <li>
  56. <img id="ja-tool-decrease" onclick="switchFontSize('ja_purity_ja_font','dec'); return false;"
  57. alt="Zmniejsz rozmiar czcionki" src="user-decrease.png" >
  58. </li>
  59. </ul>
  60.  
  61.  
  62. Napis na stronie jest jakiś
  63.  
  64.  
  65. </body>
  66. </html>
  67.  
  68.  
  69.  
  70. <pre>
  71. <?
  72. print_r($_COOKIE)
  73. ?>
  74. </pre>
kamil4u
Nie wiem co oznacza u Ciebie $E, ale już na wstępie funkcji przyjmuje ona wartość undefined i staje się lokalna, ponieważ dałeś:
Kod
Var $E;


Podejrzewam, że to funkcja globalna, więc po prostu usuń tę linię i zobacz co się stanie smile.gif

--edit--
Zmień $E na samo $
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.