Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Auto click po załadowaniu strony
wrkilu
post 1.12.2020, 23:09:54
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 1.12.2020

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


Hej,
Mam na stronie 2 buttony, które gdy się je kliknie wyświetlają na stronie jakieś odpowiednie teksty.
I teraz chciałbym aby po załadowaniu strony od raz wyświetlił się tekst tak jakby ktoś kliknął właśnie jeden z tych buttonów.


Buttony są zdefniowane tak:
Cytat
<div class="tab">
<button class="tablinks" onclick="usluga(event, 'konta-ftp')">Konta FTP</button>
<button class="tablinks" onclick="usluga(event, 'abonament')">Abonament</button>
</div>


A skrypt JS tak:
Cytat
<script>
function usluga(evt, name) {
// Declare all variables
var i, tabcontent, tablinks;

// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}

// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}

// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(name).style.display = "block";
document.getElementById(name).style.borderStyle = "hidden";

evt.currentTarget.className += " active";
}

</script>


I to jest wersja na kliknięcie ręczne, które działa.
I teraz co dodać żeby jeden z nich się automatycznie kliknął ? Będę bardzo wdzięczny za pomoc bo musze to zrobić z doskoku a programistą JSa nie jestem,
pozdrawiam

Ten post edytował wrkilu 1.12.2020, 23:10:32
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
wrkilu
post 2.12.2020, 09:51:27
Post #2





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 1.12.2020

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


Rządzisz Panie rządzisz smile.gif
działa i pozdrawiam serdecznie

Go to the top of the page
+Quote Post

Posty w temacie


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: 27.04.2024 - 09:11