<!DOCTYPE html>
<div id="target">
<button>Enter fullscreen</button>
<a href="/">link inside target</a>
</div>
<script>
const target = document.getElementById('target');
const button = document.querySelector('button');
button.addEventListener('click', function() {
target.webkitRequestFullscreen();
});
document.onwebkitfullscreenchange = function() {
const iframe = document.createElement('iframe');
iframe.srcdoc = '<a href="/">link inside iframe</a>';
document.body.appendChild(iframe);
iframe.onload = function() {
document.webkitExitFullscreen();
document.onwebkitfullscreenchange = function() {
button.setAttribute('aria-label', 'Done');
}
}
}
</script>