Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Galeria js obsługa wstecz itd.
wlamywacz
post
Post #1





Grupa: Zarejestrowani
Postów: 535
Pomógł: 27
Dołączył: 3.05.2005

Ostrzeżenie: (20%)
X----


Jak w tytule. Myślę nad tym aby do zmiennej ostanie dawać nr. ostatniej fotki. I dodawać do adresu #nr_fotki jednak jak przechwycić to że user użył cofnij? Może jakieś przykłady ? Z góry dzięki za pomoc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
misterdexter
post
Post #2





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 15.06.2005

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


Jeśli dwa razy na sekundę wykonuje się pętle, to może być problem. Odciążyć trochę przeglądarkę można po prostu sprawdzając czy zaszły zmiany, wtedy spokojnie można zwiększyć częstotliwość sprawdzania.

  1. <head>
  2. <script type='text/javascript'>
  3. var change='#'; // zmienna sprawdzajaca
  4.  
  5. function CheckForHash(){
  6. if(document.location.hash){
  7. var HashLocationName = document.location.hash;
  8.  
  9. if(HashLocationName == change) return; // jesli taka jest zakladka, nie sprawdzamy dalej
  10. change = HashLocationName; // jesli sprawdzamy, zapamietujemy
  11.  
  12. HashLocationName = HashLocationName.replace("#","");
  13. document.getElementById(HashLocationName).style.display='block';
  14. document.getElementById('Intructions').style.display='none';
  15. for(var a=0; a<5; a++){
  16. if(HashLocationName != ('Show' +(a+1))){
  17. document.getElementById('Show'+(a+1)).style.display='none';
  18. }
  19. }
  20. }else{
  21. if(change == '') return; // podobnie tutaj
  22. change = ''; // zapamietac tez trzeba
  23.  
  24. document.getElementById('Intructions').style.display='block';
  25. for(var a=0; a<5; a++){
  26. document.getElementById('Show'+(a+1)).style.display='none';
  27. }
  28. }
  29. }
  30. function RenameAnchor(anchorid, anchorname){
  31. document.getElementById(anchorid).name = anchorname; //this renames the anchor
  32. }
  33. function RedirectLocation(anchorid, anchorname, HashName){
  34. RenameAnchor(anchorid, anchorname);
  35. document.location = HashName;
  36. }
  37. var HashCheckInterval = setInterval("CheckForHash()", 100); // a sprawdzac mozna spokojnie czesciej
  38. window.onload = CheckForHash;
  39. </script>
  40. </head>
  41. <body>
  42. <a id='LocationAnchor' name=''></a>
  43. <div id='linkholder'>
  44. <a href='javascript:RedirectLocation("LocationAnchor", "Show1", "#Show1");'>Display Option 1</a><br />
  45. <a href='javascript:RedirectLocation("LocationAnchor", "Show2", "#Show2");'>Display Option 2</a><br />
  46. <a href='javascript:RedirectLocation("LocationAnchor", "Show3", "#Show3");'>Display Option 3</a><br />
  47. <a href='javascript:RedirectLocation("LocationAnchor", "Show4", "#Show4");'>Display Option 4</a><br />
  48. <a href='javascript:RedirectLocation("LocationAnchor", "Show5", "#Show5");'>Display Option 5</a>
  49. </div>
  50. <div id='Show1' style='display:none;'>
  51. 1st Option
  52. </div>
  53. <div id='Show2' style='display:none;'>
  54. 2nd Option
  55. </div>
  56. <div id='Show3' style='display:none;'>
  57. 3rd Option
  58. </div>
  59. <div id='Show4' style='display:none;'>
  60. 4th Option
  61. </div>
  62. <div id='Show5' style='display:none;'>
  63. 5th Option
  64. </div>
  65. <div id='Intructions' style='display:block;'>
  66. Click on the above links to see different values, then use the back button to see your browsing history.
  67. </div>
  68. </body>
  69. </html>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 9.10.2025 - 16:29