죄송합니다. 단순한 질문입니다. 이 모든 것이 중요한지 아닌지는 잘 모르겠지만, 다만이를 위해 언급 할 것입니다. : 사용자가 링크를 클릭하면 다음과 같이 표시됩니다.간단한 팝업을 닫는 방법을 알아낼 수 없습니다.
function begin(some info) is called->Makes an Ajax request to backend PHP->
PHP calls the callback function->Callback function calls another JS function that creates a popup->
In the popup creating function, The Save button is assigned a function that makes an ajax request and sends PHP some user input.->
PHP makes a callback to another function that does nothing.
여기는 팝업 상자를 함께 표시하는 기능입니다. 나는 팝업에 Save
버튼을 누를 때
function collection(name, description, data){
var json = data;
var cont = openSitePopup("400","300");
//We create div objects.
var namecell = ce("div","sitePopupCell");
//Stuff
// We create a button and assign the createProducts Method to it.
var sbtbutton = createBtn("submitObject","SAVE","createProducts()");
//We append all the div objects to the popup.
cont.appendChild(namecell);
//..
}
function openSitePopup(width,height) {
//try to center the popup if values are not passed
var xPos = (getWinWidth()/2) - (width/2) + sl;
var yPos = (getWinHeight()/2) - (height/2) + st;
sitepopupwin = ge("sitePopupWin");
clearElement(sitepopupwin);
var winhandle = ce("div","","sitePopupHandle");
sitepopupwin.style.display = "block";
//Other style assignments.
//closebutton
var close = ce("img","sitePopupCloseBtn");
close.setAttribute("src",theme_path + "/images/icons/close.png");
//start adding goodies
var mydiv = ce("div","sitePopupContainer");
winhandle.appendChild(close);
winhandle.appendChild(createCleaner());
sitepopupwin.appendChild(winhandle);
sitepopupwin.appendChild(mydiv);
//return reference to the container for adding stuff
return mydiv;
}
function createProducts()
{
//Some exciting Ajax stuff with a callback to writeNewFolder()
}
function writeNewFolder(data){
//Nothing of interest here...yet.
}
지금, 요청이 성공적으로 구성되어 있지만, 팝업이 닫히지 않습니다. 나는 Window.Close()
함수를 알고 있지만 작동하지 않습니다. cont.Close()
은 명백한 선택처럼 보이지만 그 경우에는이 오류가 발생합니다. Uncaught TypeError: Object #<HTMLDivElement> has no method 'Close'
그래서 Cont는 div 요소입니다. openSitePopup()
메서드는 div 만 반환합니다.
도움 주셔서 감사합니다.
편집 :
function ce(elementType,elementClass,elementId,txt) {
var e = document.createElement(elementType);
//add optional parameters
if (elementId) e.setAttribute("id",elementId);
if (elementClass) setClass(e,elementClass);
//append extra text. If passed an object, append with without the textnode wrapper
if (isData(txt)) {
if (typeof(txt)=="object") e.appendChild(txt);
else e.appendChild(ctnode(txt));
}
return e;
}
는 희망 원래 제작자 나 여기에 자신의 코드의 일부를 게시 상관하지 않습니다. 글쎄, 그것은 자유롭고 오픈 소스이기 때문에 괜찮을 것이라고 생각합니다.
편집 2 : ge
기능. 이것은 간단합니다.
function ge(element) {
return document.getElementById(element);
}
사과! 나는 ce가 표준 JavaScript 함수라고 생각했다. 기본적으로 요소를 만듭니다. – zermy
업데이트보기 ..... – mplungjan
당신의 솔루션이 효과가 있습니다. 덕분에 많이했습니다. 당신 말이 맞았습니다. 그것은 창 요소가 아니며, 단지 div였습니다. 얼마나 재미있는가. – zermy