WebSite X5Help Center

 
Martin S.
Martin S.
User

Vložení externí Javascript  en

Autor: Martin S.
Visitado 144, Seguidores 1, Compartilhado 0  

Ahoj všem,

Má tu někdo prosím zkušenosti s přidáním externího Javascript do stránky? Script vkládám vždy prostřednictvím HTML objektu a když celý kód Scriptu vložím přímo do HTML objektu tak funguje bez problémů. Ale když na Js chci jen odkázat tím, že v HTML objektu v záložce Expert nastavím spojený soubor a cesta k němu tak se Javascript nespustí. Kde je problém?  

Publicado em
7 RESPOSTAS
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator

(It > En) ... if you attached the file "immagine.jpg" to the project, leaving "files" as the default folder, the direct relative path at the same structural level is:
files/immagine.jpg
... so, an SRC attribute for pages in the ROOT directory would be:
src="files/immagine.jpg"
... if you use the JS code on special pages  or sub-pages (like a blog, cart, etc.), you need to use a relative path that traverses directories:
src="../files/immagine.jpg"
...
... or you can use the absolute path:
https://www.your-site-name.en/files/immagine.jpg
src="https://www.your-site-name.en/files/immagine.jpg"
...
... if you post your JS code and the link to the relevant page, we could avoid guesswork...

.

ciao

.

Ler mais
Publicado em de  ‪ KolAsim ‪ ‪
Martin S.
Martin S.
User
Autor

Už se mi to povedlo, funguje to chyba byla nejspíše v použitém Scriptu. Ale rád bych z důvodu lepší SEO použil defer A to netuším kam to správně vložit aby to fungovalo.

Ler mais
Publicado em de Martin S.
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator
 ‪ KolAsim ‪ ‪
... ... ...  ... ... if you post your JS code and the link to the relevant page, we could avoid guesswork... ... ... ... 

... to be able to understand what it is about...

.

Ler mais
Publicado em de  ‪ KolAsim ‪ ‪
Martin S.
Martin S.
User
Autor

Už jsem to vyřešil a funguje to. Krok 1 Hlavní nastavení, statistika a kód, před uzavřením štítkem HEAD jsem vložil:

 <script src="https://mujweb.cz/js/clock.js" defer></script>

Pak ve stránce kde hodiny chci zobrazit v HTML objektu:

<div class="clock" id="clock">

    <div class="flip" data-value="0"></div>

    <div class="flip" data-value="0"></div>

    <div class="separator"></div>

    <div class="flip" data-value="0"></div>

    <div class="flip" data-value="0"></div>

</div>

A v záložce Expert doplnit CSS.

Ler mais
Publicado em de Martin S.
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator

... in fact, it is a completely different problem and situation, which is resolved by positioning the code correctly...

.

Ler mais
Publicado em de  ‪ KolAsim ‪ ‪
Martin S.
Martin S.
User
Autor

O jaký problém jde? Kód mam umístěný špatně? Jaké tedy má být v tomto případě správné řešení?

Ler mais
Publicado em de Martin S.
 ‪ KolAsim ‪ ‪
 ‪ KolAsim ‪ ‪
Moderator

... practically in the same sections you said you used...
... it is unclear whether you are encountering any problems; if so, to assess the situation, you need to post the LINK to the page in question...
.

Ler mais
Publicado em de  ‪ KolAsim ‪ ‪