Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Nowa warstwa po kliknięciu, Zniknięcie wastwy po ponownym kliknięciu
mimol
post 11.04.2010, 09:04:20
Post #1





Grupa: Zarejestrowani
Postów: 247
Pomógł: 5
Dołączył: 10.12.2007

Ostrzeżenie: (0%)
-----


Chcę wykorzystać na stronię efekt przyciemnienia.
Znalazłem taki mały skrypt:
  1. <a href="#" onclick="grayOut(true); alert('Wyłącz');
  2. grayOut(false); return false;">Warstwa</a>
  3. <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>footer
  4. <script type="text/javascript">
  5. function grayOut(vis, options) {
  6. var options = options || {};
  7. var zindex = options.zindex || 50;
  8. var opacity = options.opacity || 70;
  9. var opaque = (opacity / 100);
  10. var bgcolor = options.bgcolor || '#000000';
  11. var dark=document.getElementById('darkenScreenObject');
  12. if (!dark) {
  13. var tbody = document.getElementsByTagName("body")[0];
  14. var tnode = document.createElement('div'); // Create the layer.
  15. tnode.style.position='absolute'; // Position absolutely
  16. tnode.style.top='0px'; // In the top
  17. tnode.style.left='0px'; // Left corner of the page
  18. tnode.style.overflow='hidden'; // Try to avoid making scroll bars
  19. tnode.style.display='none'; // Start out Hidden
  20. tnode.id='darkenScreenObject'; // Name it so we can find it later
  21. tbody.appendChild(tnode); // Add it to the web page
  22. dark=document.getElementById('darkenScreenObject'); // Get the object.
  23. }
  24. if (vis) {
  25. // Calculate the page width and height
  26. if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
  27. var pageWidth = document.body.scrollWidth+'px';
  28. var pageHeight = document.body.scrollHeight+'px';
  29. } else if( document.body.offsetWidth ) {
  30. var pageWidth = document.body.offsetWidth+'px';
  31. var pageHeight = document.body.offsetHeight+'px';
  32. } else {
  33. var pageWidth='100%';
  34. var pageHeight='100%';
  35. }
  36. //set the shader to cover the entire page and make it visible.
  37. dark.style.opacity=opaque;
  38. dark.style.MozOpacity=opaque;
  39. dark.style.filter='alpha(opacity='+opacity+')';
  40. dark.style.zIndex=zindex;
  41. dark.style.backgroundColor=bgcolor;
  42. dark.style.width= pageWidth;
  43. dark.style.height= pageHeight;
  44. dark.style.display='block';
  45. } else {
  46. dark.style.display='none';
  47. }
  48. }
  49.  

Chcę wykorzystać to w troszkę inny sposób, więc próbowałem zmodyfikować skrypt. Chcę by po kliknięciu w Warstwa pojawiała się szara warstwa (i nie wyskakiwał alert, jednakże po ponownym kliknięciu w WARSTWĘ warstwa by znikała)
Zmieniłem kod na
  1. <a href="#" onclick="grayOut(true); return false;">Warstwa</a>

Jednak nie wiem jak przypisać hrefa do warstwy by po kliknięciu w nią znikała
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 12:46