Skocz do zawartości
View in the app

A better way to browse. Learn more.

Max3D.pl

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Napisano

Chciałem stworzyć sobie skrypt do zmiany skórki/motywu na stronie i dla testu napisałem prosty skrypt w sekcji head. Niestety funkcja odpowiedzialna za wczytanie odpowiedniego arkusza css w ogóle się nie wykonuje. Nie wiem co jest źle, skrypt w head wygląda tak:

 

<br />
<br />
    <br />
    function setTheme (theme = "")<br />
    {<br />
         if(theme == "red")<br />
         document.write('<link rel="stylesheet" href="'+theme+'.css" type="text/css">');<br />
         else if(theme == "green")<br />
         document.write('<link rel="stylesheet" href="'+theme+'.css" type="text/css">');<br />
         else<br />
         document.write('<link rel="stylesheet" href="green.css" type="text/css">');<br />
    }<br />
<br />
setTheme("");<br />
    <br />

  • Odpowiedzi 3
  • Wyświetleń 1,6k
  • Created
  • Ostatniej odpowiedzi

Top Posters In This Topic

Napisano

możesz sobie wyalertować theme. osobiście nie zmieniałem linków do cssa więc nie wiem czy przypadkiem nie trzeba przeładować danych albo zrobić zamianki typu outerHTML by się wykonało.

Napisano

Witaj QbisieQ,

 

Miałeś błędzik w deklaracji zmiennej w funkcji. Teraz jest dobrze:

 

<br />
<br />
    <br />
    function setTheme (theme)<br />
    {<br />
         if(theme == "red")<br />
         document.write('<link rel="stylesheet" href="'+theme+'.css" type="text/css">');<br />
         else if(theme == "green")<br />
         document.write('<link rel="stylesheet" href="'+theme+'.css" type="text/css">');<br />
         else<br />
         document.write('<link rel="stylesheet" href="green.css" type="text/css">');<br />
    }<br />
<br />
setTheme("");<br />
    <br />

 

Dodatkow sugeruję nie używać "==", a "===". "Podwójne porównanie" jest bardziej podatne na błędy: http://www.impressivewebs.com/why-use-triple-equals-javascipt/.

 

function setTheme (theme) {
if(theme === "red")
document.write('');
else if(theme === "green")
document.write('');
else
document.write('');
}

setTheme("");

 

Pozdrawiam,

 

Artur

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Powiadomienie o plikach cookie

Wykorzystujemy cookies. Przeczytaj więcej Polityka prywatności

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.