Открыть вкладку контента по ссылке - PullRequest
0 голосов
/ 03 апреля 2020

Я хочу сослаться на указанную c вкладку из ссылки на другую страницу. Следующее - то, что я попытался (после других попыток) без удачи.

function openPage(pageName, elmnt, color) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
}

// Remove the background color of all tablinks/buttons
tablinks = document.getElementsByClassName("tablink");
for (i = 0; i < tablinks.length; i++) {
    tablinks[i].style.backgroundColor = "";
}
 var hash = window.location.hash;
// if a hash is present (when you come to this page)
if (hash != '') {
    // show the tab
    pageName = hash;
}

document.getElementById(pageName).style.display = "block";


// Add the specific color to the button used to open the tab content
elmnt.style.backgroundColor = color;
}

Затем я бы связался с ним, например, по:

<a href="http://www.website.com/contact#Plane">Go by plane</a>

, и это открыло бы эту конкретную c вкладку.

...