그래서 지금은 팝업 div (크롬 확장 용)가 있고 지금 당장 div가 정상적으로 나타납니다.div에 html 레이아웃 파일을 삽입하려면 어떻게해야합니까?
내가 뭘하고 싶은지는 내가 만든이 레이아웃 파일을 div에 넣는 것이다. 이 일에 대해 어떻게 생각 하나? 나는 어쩌면 당신은 'index.html을'파일의 내용을 얻기 위해 아약스를 사용할 수있는 index.html을에 innerHTML 속성 (레이아웃 파일)
jQuery(function($) {
// Mouse listener for any move event on the current document.
console.log("started"); //debug for starting
var popupStatus = 0; // set value
document.addEventListener('mousemove', function (e) {
var srcElement = e.srcElement;
// Lets check if our underlying element is a DIV.
if (srcElement.nodeName == 'A' || srcElement.nodeName == 'STRONG') {
loadPopup();
}
else{
disablePopup();
}
}, true);
function loadPopup() {
var x = document.getElementById("index");
if(popupStatus == 0) { // if value is 0, show popup
$('<div/>', {
id: 'cover',
innerHTML: index.html //line in question (making it "index.html" doesn't work)
}).appendTo(document.documentElement);
$('#cover').fadeTo("slow",1);
popupStatus = 1; // and set value to 1
}
}
function disablePopup() {
if(popupStatus == 1) { // if value is 1, close popup
$('#cover').fadeTo("slow",0);
$('#cover').remove();
popupStatus = 0;
}
}
});
Chrome 확장 프로그램에 대한 답변을 수정하려면 주소가 원본과 관계없이 올바른 경로를 유지하려면 'index.html'이 아니고 'chrome.runtime.getURL ("index.html")이 아니어야합니다. – Xan
감사합니다. @ 잰. 대답은 방금 솔루션 가이드로 생각하여 문제를 해결하는 방법을 제시하고 완전한 해결책은 아닙니다. Chrome 확장 프로그램에서이 문제를 알지 못해 새로운 것을 배웠습니다. – cezar
흠,이 시도했지만 이제 div 나타나지 않습니다 – BionicSheep