iframes_javascript 기술 전반에 걸쳐 js, css 및 기타 파일의 동적 로드
1. js 및 css 파일을 동적으로 로드합니다(기본 js 및 jquery 사용)
iframe 구조:
frame0(상위)
frame2(하위)
frame3(하위)
frame2에서 이벤트를 트리거하고 js, css 파일 및 dom 요소를 프레임3에 동적으로 로드하시겠습니까?
* 피어 간에 호출할 수 있으며 자식-부모-자식 방식으로 호출할 수 있습니다.
parent.parentFram("이 메서드는 다른 하위 농장을 호출합니다.")
1. jquery의 Append()
빠른 속도와 동기화(jquery 도입 필요)
var oBody = document.getElementById("frame3_id").contentWindow.$("body")
var str = "
var scriptTag = document.getElementById("frame3_id").contentWindow.document.getElementById("pop");
if(!scriptTag){
oBody.append(str );
}
var oScript= document.createElement("script");
oScript.id = "oScript1"
oScript.type = "text/javascript"; >oScript.src="/test.js";
var oTag1 = document.getElementById("frame3_id").contentWindow.document.getElementById("oScript1")
if(!oTag1){
oBody.append (oScript);
}
document.getElementById("frame3_id").contentWindow.test(); //frame3_id에서 test() 메서드 호출
위의 예: a. jquery를 도입해야 합니다.
** *********************************
appendChild() of 2.js
속도 느림, 비동기(js 로드 여부 확인 필요)
예시 2:
var popDiv=document.createElement('div'); 🎜>popDiv.style.xx = xxx ;
popDiv.id = "pop";
popDiv.innerHTML =
var oBody = document.getElementById("frame3_id").contentWindow.document.getElementsByTagName ("body")[0];
var oHead = document.getElementById("frame3_id").contentWindow.document.getElementsByTagName("head")
if(oHead && oHead.length)
oHead = oHead[0] ;
}else{
oHead = oBody;
}
var elemDivTag = document.getElementById("frame3_id").contentWindow.document.getElementById ("pop");
if(!elemDivTag){
oBody.appendChild(popDiv)
}
var oScript= document.createElement("script"); )
oScript.id = "oScript1 ";
oScript.type = "text/javascript"
oScript.src="/test.js"
var scriptTag = document.getElementById(" main").contentWindow.document.getElementById( "oScript1");
if(!scriptTag){
oHead.appendChild(oScript);
}
oScript.onload = oScript.onreadystatechange = 함수 (){
if ((! this.readyState) || this.readyState == "완료" || this.readyState == "로드됨" ){
document.getElementById("main").contentWindow. test(); // test() 메소드 가져온 js 파일에서
}else{
console.info("oScript2.js 파일을 로드할 수 없습니다.")
}
}

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Python은 헤드리스 브라우저 컬렉션 애플리케이션을 위한 동적 페이지 로딩 및 비동기 요청 처리 기능 분석을 구현합니다.

Golang의 핫 업데이트 원리 공개: 동적 로딩 및 재로딩에 대한 내부 설명

Vue 및 Element-UI를 사용하여 데이터를 동적으로 로드하는 테이블을 만드는 방법

Vue 오류 해결: Vue Router를 올바르게 사용하여 라우팅 매개변수를 기반으로 구성 요소를 동적으로 로드할 수 없습니다.

phpSpider 실용적인 팁: 웹 콘텐츠의 동적 로딩을 처리하는 방법은 무엇입니까?

Java에서 동적 클래스 로딩을 위해 ClassLoader 함수를 사용하는 방법
