Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zmiana kolejności ładowania diva
thepeche
post 17.01.2014, 00:51:01
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 17.01.2014

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


Witam!

Mam następujący problem do rozwiązania.
Otóż w moim sklepie postanowiłem wrzucić wyszukiwarkę google w nagłówek strony.
Jednak sama wyszukiwarka dość długo laduje się przy wejściu na stronę i zatrzymuje ładowanie się reszty strony do czasu aż sama się załaduje.
Chciałbym by div zawierający wyszukiwarkę był pomijany w ładowaniu strony dopóki strona cała się nie zaladuje. Wtedy zaczynała by sie ładowac dopiero wyszukiwarka.


Bardziej obrazowo:

<header>
<div1>
<div id="Wyszukiwarka"><--chciałbym by div był pomijany w ładowaniu strony dopóki strona cała się nie zaladuje. Wtedy zaczynała by sie ładowac dopiero wyszukiwarka.
<div1>
<div1>
itd...
</header>

<strona>
...
...
...
</strona>

<footer>
....
</footer>

Oswiadczam, że jestem absolutnie zielony w te sprawy, jednak bardzo dziękuje gdyby ktoś zechciał wspomóc mnie jakimś skryptem, który zrealizował by moje założenie.

Pozdrawiam!
Go to the top of the page
+Quote Post
SaMi
post 17.01.2014, 15:53:22
Post #2





Grupa: Zarejestrowani
Postów: 173
Pomógł: 14
Dołączył: 27.03.2004
Skąd: Białystok

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


uzyj onload


--------------------
Zapraszam na spływy kajakowe rzekami podlasia www.splywy-kajakiem.pl
Go to the top of the page
+Quote Post
sowiq
post 17.01.2014, 16:02:48
Post #3





Grupa: Zarejestrowani
Postów: 1 890
Pomógł: 339
Dołączył: 14.12.2006
Skąd: Warszawa

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


Ładuj Ajaxem snitch.gif

jQuery.load()
Go to the top of the page
+Quote Post
lukasz1985
post 17.01.2014, 16:08:15
Post #4





Grupa: Zarejestrowani
Postów: 205
Pomógł: 43
Dołączył: 5.03.2012

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


Najpierw usuń zawartość diva wyszukiwarka (ma być pusty w HTMLu). Potem dodaj:

  1. <script type="text/javascript>
  2.  
  3. window.addEventListener("load", function() {
  4. document.getElementById("Wyszkukiwarka").innerHTML = "TUTAJ KOD HTML WYSZUKIWARKI GOOGLA";
  5. })
  6.  
Go to the top of the page
+Quote Post
thepeche
post 18.01.2014, 11:52:53
Post #5





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 17.01.2014

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


Dziękuje bardzo lukasz1985.

Niestety cos "przeszkadza" i kod nie wykonuje sie poprawnie, czy są to może style css zawarte w kodzie html?
Czy kod mam umiescić w nagłówku gdzie chce by sie wyswietłał div, czy w footer, czyli jak załaduje sie stopka, ktora jest ostatnim elementem do wczytania na stronie?

  1.  
  2. <div="wyszukiwarkaGoogle"></div>
  3.  
  4.  
  5. <script type="text/javascript>
  6.  
  7.  
  8.  
  9. window.addEventListener("load", function() {
  10.  
  11. document.getElementById("wyszukiwarkaGoogle").innerHTML = "
  12. <div id='cse' style="width:37.3%; position:absolute; top:180px; left:72px;">Loading</div>
  13. <script src='//www.google.com/jsapi' type='text/javascript'></script>
  14. <script type='text/javascript'>
  15. google.load('search', '1', {language: 'pl', style: google.loader.themes.V2_DEFAULT});
  16. google.setOnLoadCallback(function() {
  17. var customSearchOptions = {};
  18. var orderByOptions = {};
  19. orderByOptions['keys'] = [{label: 'Relevance', key: ''} , {label: 'Date', key: 'date'}];
  20. customSearchOptions['enableOrderBy'] = true;
  21. customSearchOptions['orderByOptions'] = orderByOptions;
  22. customSearchOptions['overlayResults'] = true;
  23. var customSearchControl = new google.search.CustomSearchControl('011599289272865291231:-i9dlxieymi', customSearchOptions);
  24. customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  25. var options = new google.search.DrawOptions();
  26. options.setAutoComplete(true);
  27. customSearchControl.draw('cse', options);
  28. }, true);
  29. <style type='text/css'>
  30. .gsc-control-cse {
  31. font-family: Arial, sans-serif;
  32. border-color: #FFFFFF;
  33. background-color:#F0E7D6;
  34. padding:0px 0px 0px 0px;
  35. background:none;
  36. border:none;
  37.  
  38.  
  39.  
  40. }
  41. .gsc-control-cse .gsc-table-result {
  42. font-family: Arial, sans-serif;
  43. }
  44. input.gsc-input, .gsc-input-box, .gsc-input-box-hover, .gsc-input-box-focus {
  45. border-color: #D9D9D9;
  46. }
  47. input.gsc-search-button, input.gsc-search-button:hover, input.gsc-search-button:focus {
  48. border-color: #666666;
  49. background-color: #F0E7D6/*#CECECE*/;
  50. background-image: none;
  51. /*background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#5b4636), to(#7d6957));
  52. background-image: -webkit-linear-gradient(top, #5b4636, #7d6957);
  53. background-image: -moz-linear-gradient(top, #5b4636, #7d6957);
  54. background-image: -ms-linear-gradient(top, #5b4636, #7d6957);
  55. background-image: -o-linear-gradient(top, #5b4636, #7d6957);
  56. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5b4636', endColorstr='#7d6957');*/
  57. /* filter: none;*/
  58.  
  59.  
  60. }
  61. .gsc-tabHeader.gsc-tabhInactive {
  62. border-color: #FF9900;
  63. background-color: #ffffff;
  64. }
  65. .gsc-tabHeader.gsc-tabhActive {
  66. border-color: #E9E9E9;
  67. background-color: #E9E9E9;
  68. border-bottom-color: #FF9900
  69. }
  70. .gsc-tabsArea {
  71. border-color: #FF9900;
  72. }
  73. .gsc-webResult.gsc-result, .gsc-results .gsc-imageResult {
  74. border-color: #FFFFFF;
  75. background-color: #FFFFFF;
  76. }
  77. .gsc-webResult.gsc-result:hover, .gsc-imageResult:hover {
  78. border-color: #FFFFFF;
  79. background-color: #FFFFFF;
  80. }
  81. .gs-webResult.gs-result a.gs-title:link, .gs-webResult.gs-result a.gs-title:link b, .gs-imageResult a.gs-title:link, .gs-imageResult a.gs-title:link b {
  82. color: #0000CC;
  83. }
  84. .gs-webResult.gs-result a.gs-title:visited, .gs-webResult.gs-result a.gs-title:visited b, .gs-imageResult a.gs-title:visited, .gs-imageResult a.gs-title:visited b {
  85. color: #0000CC;
  86. }
  87. .gs-webResult.gs-result a.gs-title:hover, .gs-webResult.gs-result a.gs-title:hover b, .gs-imageResult a.gs-title:hover, .gs-imageResult a.gs-title:hover b {
  88. color: #0000CC;
  89. }
  90. .gs-webResult.gs-result a.gs-title:active, .gs-webResult.gs-result a.gs-title:active b, .gs-imageResult a.gs-title:active, .gs-imageResult a.gs-title:active b {
  91. color: #0000CC;
  92. }
  93. .gsc-cursor-page {
  94. color: #0000CC;
  95. }
  96. a.gsc-trailing-more-results:link {
  97. color: #0000CC;
  98. }
  99. .gs-webResult .gs-snippet, .gs-imageResult .gs-snippet, .gs-fileFormatType {
  100. color: #000000;
  101. }
  102. .gs-webResult div.gs-visibleUrl, .gs-imageResult div.gs-visibleUrl {
  103. color: #008000;
  104. }
  105. .gs-webResult div.gs-visibleUrl-short {
  106. color: #008000;
  107. }
  108. .gs-webResult div.gs-visibleUrl-short {
  109. display: none;
  110. }
  111. .gs-webResult div.gs-visibleUrl-long {
  112. display: block;
  113. }
  114. .gs-promotion div.gs-visibleUrl-short {
  115. display: none;
  116. }
  117. .gs-promotion div.gs-visibleUrl-long {
  118. display: block;
  119. }
  120. .gsc-cursor-box {
  121. border-color: #FFFFFF;
  122. }
  123. .gsc-results .gsc-cursor-box .gsc-cursor-page {
  124. border-color: #E9E9E9;
  125. background-color: #FFFFFF;
  126. color: #0000CC;
  127. }
  128. .gsc-results .gsc-cursor-box .gsc-cursor-current-page {
  129. border-color: #FF9900;
  130. background-color: #FFFFFF;
  131. color: #0000CC;
  132. }
  133. .gsc-webResult.gsc-result.gsc-promotion {
  134. border-color: #336699;
  135. background-color: #FFFFFF;
  136. }
  137. .gsc-completion-title {
  138. color: #0000CC;
  139. }
  140. .gsc-completion-snippet {
  141. color: #000000;
  142. }
  143. .gs-promotion a.gs-title:link,.gs-promotion a.gs-title:link *,.gs-promotion .gs-snippet a:link {
  144. color: #0000CC;
  145. }
  146. .gs-promotion a.gs-title:visited,.gs-promotion a.gs-title:visited *,.gs-promotion .gs-snippet a:visited {
  147. color: #0000CC;
  148. }
  149. .gs-promotion a.gs-title:hover,.gs-promotion a.gs-title:hover *,.gs-promotion .gs-snippet a:hover {
  150. color: #0000CC;
  151. }
  152. .gs-promotion a.gs-title:active,.gs-promotion a.gs-title:active *,.gs-promotion .gs-snippet a:active {
  153. color: #0000CC;
  154. }
  155. .gs-promotion .gs-snippet, .gs-promotion .gs-title .gs-promotion-title-right, .gs-promotion .gs-title .gs-promotion-title-right * {
  156. color: #000000;
  157. }
  158. .gs-promotion .gs-visibleUrl,.gs-promotion .gs-visibleUrl-short {
  159. color: #008000;
  160. }
  161.  
  162. ";})
  163.  
  164. </script>
  165.  


Go to the top of the page
+Quote Post
owca_82
post 18.01.2014, 13:23:59
Post #6





Grupa: Zarejestrowani
Postów: 77
Pomógł: 8
Dołączył: 22.04.2012

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


Cytat(lukasz1985 @ 17.01.2014, 16:08:15 ) *
  1. <script type="text/javascript>
  2. window.addEventListener("load", function() {
  3. document.getElementById("Wyszkukiwarka").innerHTML = "TUTAJ KOD HTML WYSZUKIWARKI GOOGLA";
  4. })


"addEventListener" nie jest obsługiwany przez IE
Go to the top of the page
+Quote Post
lukasz1985
post 18.01.2014, 22:37:05
Post #7





Grupa: Zarejestrowani
Postów: 205
Pomógł: 43
Dołączył: 5.03.2012

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


Jednak powinno to być trochę inaczej bo mieszają się znaki cudzysłowia i najprawdopodobniej wyskakuje błąd. Trzeba z tego kodu wyszukiwarki wyciąć to, co znajduje się w znacznikach <script> </script>, rezultat powinien wyglądać niej więcej tak:

To co ma być w HTMLu, style, wiadomo, można umieścić w nagłówku:

  1.  
  2. <div id="wyszukiwarkaGoogle">
  3. <div id='cse' style="width:37.3%; position:absolute; top:180px; left:72px;">Loading</div>
  4.  
  5. <script src='//www.google.com/jsapi' type='text/javascript'></script>
  6.  
  7. </div>
  8.  
  9. <style type='text/css'>
  10.  
  11. .gsc-control-cse {
  12.  
  13. font-family: Arial, sans-serif;
  14.  
  15. border-color: #FFFFFF;
  16.  
  17. background-color:#F0E7D6;
  18.  
  19. padding:0px 0px 0px 0px;
  20.  
  21. background:none;
  22.  
  23. border:none;
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. }
  32.  
  33. .gsc-control-cse .gsc-table-result {
  34.  
  35. font-family: Arial, sans-serif;
  36.  
  37. }
  38.  
  39. input.gsc-input, .gsc-input-box, .gsc-input-box-hover, .gsc-input-box-focus {
  40.  
  41. border-color: #D9D9D9;
  42.  
  43. }
  44.  
  45. input.gsc-search-button, input.gsc-search-button:hover, input.gsc-search-button:focus {
  46.  
  47. border-color: #666666;
  48.  
  49. background-color: #F0E7D6/*#CECECE*/;
  50.  
  51. background-image: none;
  52.  
  53. /*background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#5b4636), to(#7d6957));
  54.  
  55. background-image: -webkit-linear-gradient(top, #5b4636, #7d6957);
  56.  
  57. background-image: -moz-linear-gradient(top, #5b4636, #7d6957);
  58.  
  59. background-image: -ms-linear-gradient(top, #5b4636, #7d6957);
  60.  
  61. background-image: -o-linear-gradient(top, #5b4636, #7d6957);
  62.  
  63. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5b4636', endColorstr='#7d6957');*/
  64.  
  65. /* filter: none;*/
  66.  
  67.  
  68.  
  69.  
  70.  
  71. }
  72.  
  73. .gsc-tabHeader.gsc-tabhInactive {
  74.  
  75. border-color: #FF9900;
  76.  
  77. background-color: #ffffff;
  78.  
  79. }
  80.  
  81. .gsc-tabHeader.gsc-tabhActive {
  82.  
  83. border-color: #E9E9E9;
  84.  
  85. background-color: #E9E9E9;
  86.  
  87. border-bottom-color: #FF9900
  88.  
  89. }
  90.  
  91. .gsc-tabsArea {
  92.  
  93. border-color: #FF9900;
  94.  
  95. }
  96.  
  97. .gsc-webResult.gsc-result, .gsc-results .gsc-imageResult {
  98.  
  99. border-color: #FFFFFF;
  100.  
  101. background-color: #FFFFFF;
  102.  
  103. }
  104.  
  105. .gsc-webResult.gsc-result:hover, .gsc-imageResult:hover {
  106.  
  107. border-color: #FFFFFF;
  108.  
  109. background-color: #FFFFFF;
  110.  
  111. }
  112.  
  113. .gs-webResult.gs-result a.gs-title:link, .gs-webResult.gs-result a.gs-title:link b, .gs-imageResult a.gs-title:link, .gs-imageResult a.gs-title:link b {
  114.  
  115. color: #0000CC;
  116.  
  117. }
  118.  
  119. .gs-webResult.gs-result a.gs-title:visited, .gs-webResult.gs-result a.gs-title:visited b, .gs-imageResult a.gs-title:visited, .gs-imageResult a.gs-title:visited b {
  120.  
  121. color: #0000CC;
  122.  
  123. }
  124.  
  125. .gs-webResult.gs-result a.gs-title:hover, .gs-webResult.gs-result a.gs-title:hover b, .gs-imageResult a.gs-title:hover, .gs-imageResult a.gs-title:hover b {
  126.  
  127. color: #0000CC;
  128.  
  129. }
  130.  
  131. .gs-webResult.gs-result a.gs-title:active, .gs-webResult.gs-result a.gs-title:active b, .gs-imageResult a.gs-title:active, .gs-imageResult a.gs-title:active b {
  132.  
  133. color: #0000CC;
  134.  
  135. }
  136.  
  137. .gsc-cursor-page {
  138.  
  139. color: #0000CC;
  140.  
  141. }
  142.  
  143. a.gsc-trailing-more-results:link {
  144.  
  145. color: #0000CC;
  146.  
  147. }
  148.  
  149. .gs-webResult .gs-snippet, .gs-imageResult .gs-snippet, .gs-fileFormatType {
  150.  
  151. color: #000000;
  152.  
  153. }
  154.  
  155. .gs-webResult div.gs-visibleUrl, .gs-imageResult div.gs-visibleUrl {
  156.  
  157. color: #008000;
  158.  
  159. }
  160.  
  161. .gs-webResult div.gs-visibleUrl-short {
  162.  
  163. color: #008000;
  164.  
  165. }
  166.  
  167. .gs-webResult div.gs-visibleUrl-short {
  168.  
  169. display: none;
  170.  
  171. }
  172.  
  173. .gs-webResult div.gs-visibleUrl-long {
  174.  
  175. display: block;
  176.  
  177. }
  178.  
  179. .gs-promotion div.gs-visibleUrl-short {
  180.  
  181. display: none;
  182.  
  183. }
  184.  
  185. .gs-promotion div.gs-visibleUrl-long {
  186.  
  187. display: block;
  188.  
  189. }
  190.  
  191. .gsc-cursor-box {
  192.  
  193. border-color: #FFFFFF;
  194.  
  195. }
  196.  
  197. .gsc-results .gsc-cursor-box .gsc-cursor-page {
  198.  
  199. border-color: #E9E9E9;
  200.  
  201. background-color: #FFFFFF;
  202.  
  203. color: #0000CC;
  204.  
  205. }
  206.  
  207. .gsc-results .gsc-cursor-box .gsc-cursor-current-page {
  208.  
  209. border-color: #FF9900;
  210.  
  211. background-color: #FFFFFF;
  212.  
  213. color: #0000CC;
  214.  
  215. }
  216.  
  217. .gsc-webResult.gsc-result.gsc-promotion {
  218.  
  219. border-color: #336699;
  220.  
  221. background-color: #FFFFFF;
  222.  
  223. }
  224.  
  225. .gsc-completion-title {
  226.  
  227. color: #0000CC;
  228.  
  229. }
  230.  
  231. .gsc-completion-snippet {
  232.  
  233. color: #000000;
  234.  
  235. }
  236.  
  237. .gs-promotion a.gs-title:link,.gs-promotion a.gs-title:link *,.gs-promotion .gs-snippet a:link {
  238.  
  239. color: #0000CC;
  240.  
  241. }
  242.  
  243. .gs-promotion a.gs-title:visited,.gs-promotion a.gs-title:visited *,.gs-promotion .gs-snippet a:visited {
  244.  
  245. color: #0000CC;
  246.  
  247. }
  248.  
  249. .gs-promotion a.gs-title:hover,.gs-promotion a.gs-title:hover *,.gs-promotion .gs-snippet a:hover {
  250.  
  251. color: #0000CC;
  252.  
  253. }
  254.  
  255. .gs-promotion a.gs-title:active,.gs-promotion a.gs-title:active *,.gs-promotion .gs-snippet a:active {
  256.  
  257. color: #0000CC;
  258.  
  259. }
  260.  
  261. .gs-promotion .gs-snippet, .gs-promotion .gs-title .gs-promotion-title-right, .gs-promotion .gs-title .gs-promotion-title-right * {
  262.  
  263. color: #000000;
  264.  
  265. }
  266.  
  267. .gs-promotion .gs-visibleUrl,.gs-promotion .gs-visibleUrl-short {
  268.  
  269. color: #008000;
  270.  
  271. }
  272.  
  273.  
  274.  
  275.  
  276.  



natomiast to ma być osobno, najlepiej w nagłówku:


  1.  
  2. <script type="text/javascript">
  3.  
  4.  
  5. var searchBarLoadListener = function() {
  6. google.load('search', '1', {language: 'pl', style: google.loader.themes.V2_DEFAULT});
  7.  
  8. google.setOnLoadCallback(function() {
  9.  
  10. var customSearchOptions = {};
  11.  
  12. var orderByOptions = {};
  13.  
  14. orderByOptions['keys'] = [{label: 'Relevance', key: ''} , {label: 'Date', key: 'date'}];
  15.  
  16. customSearchOptions['enableOrderBy'] = true;
  17.  
  18. customSearchOptions['orderByOptions'] = orderByOptions;
  19.  
  20. customSearchOptions['overlayResults'] = true;
  21.  
  22. var customSearchControl = new google.search.CustomSearchControl('011599289272865291231:-i9dlxieymi', customSearchOptions);
  23.  
  24. customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  25.  
  26. var options = new google.search.DrawOptions();
  27.  
  28. options.setAutoComplete(true);
  29.  
  30. customSearchControl.draw('cse', options);
  31.  
  32. }, true);
  33.  
  34. }
  35.  
  36.  
  37.  
  38. var isIE = window.attachEvent;
  39.  
  40. if (isIE) {
  41.  
  42. (window.attachEvent("onload", searchBarLoadListener));
  43.  
  44. }
  45.  
  46. else {
  47.  
  48. (window.addEventListener("load", searchBarLoadListener));
  49.  
  50. }
  51.  
  52.  
  53.  
  54.  



Mam nadzieje, że pomoże.

Ten post edytował lukasz1985 18.01.2014, 22:38:14
Go to the top of the page
+Quote Post
szagi3891
post 21.01.2014, 02:19:18
Post #8





Grupa: Zarejestrowani
Postów: 109
Pomógł: 9
Dołączył: 12.03.2007
Skąd: kraków/tarnobrzeg/baranów/suchorzów

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


Zobacz : https://github.com/szagi3891/autoloadjs

Żeby strona nie muliła to trzeba przerzucić się na asynchroniczne ładowanie bibliotek.
W przykładzie demo jest użyta biblioteka googla odpowiedzialna za wykresy (też mocno muli stronę jeśli ją osadzimy nieasynchronicznie).

Analogicznie możesz sobie skonfigurować szukajkę.


--------------------

Każdy z was jest łodzią w której
Może się z potopem mierzyć
Cało wyjść z burzowej chmury
Musi tylko w to uwierzyć!
Go to the top of the page
+Quote Post

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: 9.06.2024 - 06:02