У нас есть страница HTML, которая выступает в качестве шлюза для нескольких приложений. На сайте есть несколько кнопок и рамка. При нажатии кнопки мы загружаем другие HTML страницы внутри IFRMAE. Все это работает нормально. Но мы хотим использовать HTML импорт / веб-компоненты при поддержке IE 11 для достижения того же. Я хочу локализовать область этой HTML страницы, которую мы импортируем, чтобы она не мешала существующему приложению.
Как мы можем этого достичь? Есть ли недостатки этого подхода.
Это то, что у нас сейчас есть.
Указатель. html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Test</title>
<script src="https://code.jquery.com/jquery-3.5.0.min.js"
integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script>
<script>
$(document).ready(function () {
$("#btnAbout").click(function () {
document.getElementById('iframe').src = "about.html";
});
$("#btnContact").click(function () { $("#iframe").attr("src", "contact.html") });
$("#btnApple").click(function () {
document.getElementById('iframe').src = "https://www.Apple.com/";
});
});
</script>
<style>
body {
height: 96vh;
padding: 0;
}
</style>
</head>
<body style="border: 1px;border-style: dashed; color: brown;">
<div>
<input type="button" value="Yahoo" id="btnAbout" />
<input type="button" value="MS" id="btnContact" />
<input type="button" value="Apple" id="btnApple" />
</div>
<iframe id="iframe" width="100%" height="96%"></iframe>
</body>
</html>
О. html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title> About</title>
</head>
<body>
<div style="border-style: dotted; color: crimson; height: 1000px;">
this is a div
</div>
</body>
</html>
Пользователь . html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
</head>
<body>
<div>
user page
</div>
</body>
</html>
Контакт. html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
</head>
<body>
<div>
this is content page
</div>
</body>
</html>