<label for="html-selector">Выберите страницу:</label>
<select id="html-selector">
<option value="">-- Выберите --</option>
<option value="/wp-content/custom-html/page1.html">Страница 1</option>
<option value="/wp-content/custom-html/page2.html">Страница 2</option>
</select>
<div id="html-content" style="margin-top: 20px; border: 1px solid #ccc; padding: 20px;"></div>
<script>
document.getElementById('html-selector').addEventListener('change', function () {
const url = this.value;
if (!url) return;
fetch(url)
.then(r => {
if (!r.ok) throw new Error("Ошибка загрузки HTML");
return r.text();
})
.then(html => {
document.getElementById('html-content').innerHTML = html;
})
.catch(err => {
document.getElementById('html-content').innerHTML = `<p style="color:red;">${err.message}</p>`;
});
});
</script>