이 문제에 대한 제안은 Custom elements을 사용하고 one of its callbacks에 자바 스크립트를 첨부하는 것입니다. W3C 문서에서 알 수 있듯이 :
사용자 지정 요소는 작성자가 모든 기능을 갖춘 DOM 요소를 작성할 수있는 방법을 제공합니다. Custom 요소에서 캡슐화 된 자바 스크립트의
Here's an example 기본적으로 :
var HTMLCustomElement = Object.create(HTMLElement.prototype);
HTMLCustomElement.createdCallback = function() {
// Put the callback function here and attach the HTML to the current element
// Define the element
var NewElement = document.registerElement('new-element', {
prototype: HTMLCustomElement
});
// instanciate the custom element
var newElement = new NewElement();
document.body.appendChild(newElement);
아니요, 그림자 DOM의 일부가 아닙니다. (그렇다고하더라도 "결국 모든 탭을 열 수있는") 신뢰할 수없는 코드를 실행해서는 안됩니다. –
arf. 고마워요. 요르단. 나는 미래 버전의 변화에 대비해 질문을 공개한다. –
그림자 DOM에 샌드 박스 iframe 넣기 ... – Supersharp