Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Problem] Ustawianie wysokości PopUpa
Forum PHP.pl > Forum > Po stronie przeglądarki > JavaScript
Rakom111
Oto skrypt:

  1. <script language="javascript">
  2.  
  3. $(document).ready(function() {
  4.  
  5. //Change these values to style your modal popup
  6. var align = 'center'; //Valid values; left, right, center
  7. var top = 10; //Use an integer (in pixels)
  8. var width = 1500; //Use an integer (in pixels)
  9. var padding = 10; //Use an integer (in pixels)
  10. var backgroundColor = '#FFFFFF'; //Use any hex code
  11. var source = 'Mapy/tekkit.html'; /
  12. var borderColor = '#333333'; //Use any hex code
  13. var borderWeight = 2; //Use an integer (in pixels)
  14. var borderRadius = 5; //Use an integer (in pixels)
  15. var fadeOutTime = 300; //Use any integer, 0 = no fade
  16. var disableColor = '#666666'; //Use any hex code
  17. var disableOpacity = 40; //Valid range 0-100
  18. var loadingImage = 'js/loading.gif'; //Use relative path from this page
  19.  
  20. //This method initialises the modal popup
  21. $(".modal").click(function() {
  22. modalPopup(align, top, width, padding, disableColor, disableOpacity, backgroundColor, borderColor, borderWeight, borderRadius, fadeOutTime, source, loadingImage);
  23. });
  24.  
  25. //This method hides the popup when the escape key is pressed
  26. $(document).keyup(function(e) {
  27. if (e.keyCode == 27) {
  28. closePopup(fadeOutTime);
  29. }
  30. });
  31.  
  32. });
  33.  
  34. </script>


używam:

jquery.js
modal.popup.js

w modal.popup.js próbowałem zrobić:

  1. document.getElementById('outerModalPopupDiv').style.display='block';
  2. document.getElementById('outerModalPopupDiv').style.width = width + 'px';
  3. document.getElementById('outerModalPopupDiv').style.height = height + 'px'; <-
  4. document.getElementById('outerModalPopupDiv').style.padding = borderWeight + 'px';
  5. document.getElementById('outerModalPopupDiv').style.background = borderColor;
  6. document.getElementById('outerModalPopupDiv').style.borderRadius = borderRadius + 'px';
  7. document.getElementById('outerModalPopupDiv').style.MozBorderRadius = borderRadius + 'px';
  8. document.getElementById('outerModalPopupDiv').style.WebkitBorderRadius = borderRadius + 'px';
  9. document.getElementById('outerModalPopupDiv').style.borderWidth = 0 + 'px';
  10. document.getElementById('outerModalPopupDiv').style.position = 'absolute';
  11. document.getElementById('outerModalPopupDiv').style.zIndex = 100;
  12.  
  13. document.getElementById('innerModalPopupDiv').style.padding = padding + 'px';
  14. document.getElementById('innerModalPopupDiv').style.background = backgroundColor;
  15. document.getElementById('innerModalPopupDiv').style.borderRadius = (borderRadius - 3) + 'px';
  16. document.getElementById('innerModalPopupDiv').style.MozBorderRadius = (borderRadius - 3) + 'px';
  17. document.getElementById('innerModalPopupDiv').style.WebkitBorderRadius = (borderRadius - 3) + 'px';
  18.  
  19. document.getElementById('blockModalPopupDiv').style.width = 100 + '%';
  20. document.getElementById('outerModalPopupDiv').style.height = 100 + '%'; <-
  21. document.getElementById('blockModalPopupDiv').style.border = 0 + 'px';
  22. document.getElementById('blockModalPopupDiv').style.padding = 0 + 'px';
  23. document.getElementById('blockModalPopupDiv').style.margin = 0 + 'px';
  24. document.getElementById('blockModalPopupDiv').style.background = disableColor;
  25. document.getElementById('blockModalPopupDiv').style.opacity = (disableOpacity / 100);
  26. document.getElementById('blockModalPopupDiv').style.filter = 'alpha(Opacity=' + disableOpacity + ')';
  27. document.getElementById('blockModalPopupDiv').style.zIndex = 99;
  28. document.getElementById('blockModalPopupDiv').style.position = 'fixed';
  29. document.getElementById('blockModalPopupDiv').style.top = 0 + 'px';
  30. document.getElementById('blockModalPopupDiv').style.left = 0 + 'px';


i w skypcie dodać
  1. var height = 800;


lecz w tedy cały skrypt nie działał
kamil4u
Zobacz co pokazuje konsola błędów. Na 70% chodzi o to, że nie masz załadowanego DOM-u. Cały ten kod co podałeś( ten Twój z getElementById ) wstaw w:
Kod
onload = function(){
/* Tu Twój kod */
}


--edit--
Aha. I ten kod umieść najlepiej w osobnym pliku JS, a nie że coś dodajesz w modal.popup.js
gr56
Dopisując w swoim skrypcie zmienną height obok pozostałych zmiennych sprawiasz że jest ona dostępna tylko w środku $(document).ready a więc nie w modal.popup.js i stąd ten błąd. Musisz utworzyć tą zmienną globalnie lub dodać do funkcji modalPopup() argument height zarówno w twoim skrypcie jak i w definicji tej funkcji w modal.popup.js
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.