Я пытаюсь создать ссылку <a>
на html-странице 1, которая переводит пользователя на html-страницу 2. После загрузки html-страницы 2 я хочу выполнить раскрывающуюся функцию. По сути, это ссылка с html-страницы 1 на html2.
Я не очень хорошо разбираюсь в javascript, но я пробовал все, что смог найти, и ничего не работает. Связь между страницами работает, но я не могу заставить раскрывающуюся функцию работать при загрузке html-страницы 2.
Любая помощь будет принята с благодарностью
HTML-страница 1
<a class="link2index" href="index2.html#test" onclick ="f();return false;">Read more about technology hubs in South Africa</a>
<script>
function f(){
testwindow = window.load("index2.html#test"); //this is working to load but not to load the dropdown
//testwindow.addEventListener('click', myFunction38()); not working
//window.onload = myFunction38 ()
//testwindow.addEventListener('load', myFunction38()){
//document.getElementById("myDropdown38").classList.toggle("show");}; not working
//window.open('index2.html');
//window.somefunction = myFunction38(){
//document.getElementById("myDropdown38").classList.toggle("show");} not working
}
</script>
HTML-страница 2, на которую я нацеливаюсь
<div class="dropdown">
<button id="test" onclick="myFunction38()" class="dropbtn">Cape Town</button>
<div id="myDropdown38" class="dropdown-content">
<a href="#">
<img src="media/capetown.jpg" alt="South Africa">
Cape Town-based Labsorganises digital and entrepreneurship bootcamps, and provides an investment of up to $20,000 for every social enterprise developed through their program.
</a>
</div>
</div>
<script>
function myFunction38() {
document.getElementById("myDropdown38").classList.toggle("show");
}
</script>