facebook type multiply 채팅 상자를 표시하는 스크립트를 수집합니다. 이 자바 스크립트 코드에서는 Iframe을 사용하여 채팅 페이지를로드했습니다. 하지만 이제 iframe을 피하고 싶습니다. 자바 스크립트에 대한 충분한 지식이 없습니다.jquery로 jquery가 전송되지 않음
이 스크립트를 위해 JavaScript로 내 채팅 페이지를로드하는 방법이 있습니다. 또는 jquery에서이 스크립트를 전송하면 어디에서 문제가 발생합니까?
자바 스크립트 :
function register_popup(id, name, cmd, pmd)
{
for(var iii = 0; iii < popups.length; iii++)
{
//already registered. Bring it to front.
if(id == popups[iii])
{
Array.remove(popups, iii);
popups.unshift(id);
calculate_popups();
return;
}
}
var element = '<div class="popup-box chat-popup cy'+id+'" id="'+ id +'">';
//if avoid iframe how to load chat page
element = element + '<div class="popup-messages"><iframe src="../chat.php?u='+ cmd +'" frameborder="0" id="iFrame1" name="CmainFrame" width="100%" height="249" style="overflow:hidden" class="if'+ cmd +'"></div></div>';
document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML + element;
popups.unshift(id);
calculate_popups();
}
function calculate_popups()
{
var width = window.innerWidth;
if(width < 540)
{
total_popups = 0;
}
else
{
width = width - 200;
//320 is width of a single popup box
total_popups = parseInt(width/320);
}
display_popups();
}
function display_popups()
{
var right = 220;
var iii = 0;
for(iii; iii < total_popups; iii++)
{
if(popups[iii] != undefined)
{
var element = document.getElementById(popups[iii]);
element.style.right = right + "px";
right = right + 320;
element.style.display = "block";
}
}
for(var jjj = iii; jjj < popups.length; jjj++)
{
var element = document.getElementById(popups[jjj]);
element.style.display = "none";
}
}
//recalculate when window is loaded and also when window is resized.
window.addEventListener("resize", calculate_popups);
window.addEventListener("load", calculate_popups);
//this function can remove a array element.
Array.remove = function(array, from, to) {
var rest = array.slice((to || from) + 1 || array.length);
array.length = from < 0 ? array.length + from : from;
return array.push.apply(array, rest);
};
가 JQuery와 같은 시도 : 나는 밀접하게 코드를 분석하지 않았다
function register_popup(id, name, cmd, pmd)
{
for(var iii = 0; iii < popups.length; iii++)
{
//already registered. Bring it to front.
if(id == popups[iii])
{
Array.remove(popups, iii);
popups.unshift(id);
calculate_popups(); //alert(popups(id));
return;
}
}
$("<div></div>").attr('id',id).append('<div class="popup-box chat-popup cy'+id+'" id="'+ id +'"><div class="popup-messages"><div id="iFrame1" name="CmainFrame" width="100%" height="249" style="overflow:hidden" class="if'+ cmd +'"><object type="text/html" data="../chat.php?u='+ cmd +'"></div></div></div>');
popups.unshift(id);
calculate_popups();
}
function display_popups()
{
var right = 220;
var iii = 0;
for(iii; iii < total_popups; iii++)
{
if(popups[iii] != undefined)
{
right = 220 + 320;
$("#"+popups[iii]).css({"display": "block", "right": "right"}).show();
}
}
for(var jjj = iii; jjj < popups.length; jjj++)
{
$("#"+popups[jjj]).css("display", "none");
}
}
//others function remain same
글쎄, 어떻게하면 어떻게됩니까? – Malvolio
표시 없음 ... – koc
표시 할 이유가 표시되지 않습니다. DOM에 아무 것도 추가하지 마십시오. – Malvolio