したらばTOP ■掲示板に戻る■ 全部 1-100 最新50 | メール | |

管理人の独り言(プログラミング関連)

553774さん:2008/10/10(金) 05:37:39 ID:CENbthlg0
function ShowPopup(menus, x, y, cl){
if(typeof(cl) == "undefined") cl = "";

//documentを渡すと、要素を返す
var create = function(d){
var div = d.createElement("div");
var objs = [];
div.className = cl;

var i, c;
for(i = 0; c = menus[i]; ++i){
var div_ = d.createElement("div");
objs.push(div_);
div_.innerText = c.str;
div.appendChild(div_);
}

return {ele:div, menus: objs};
};

if(menus && menus.length){
//必要な要素の大きさを測定
var div = create(d);
with(div.ele.style){
position = "absolute";
top = left = "0px";
}

body.appendChild(div.ele);
var size = {w: div.ele.offsetWidth, h: div.ele.offsetHeight};
body.removeChild(div.ele);

//本処理
var p = w.createPopup();

with(p.document){
open();
write("<!DOCTYPE html>\r\n");
write("<html><head></head><body></body></html>");
close();
}

var popup_html = p.document.getElementsByTagName("html").item(0);
var popup_body = p.document.getElementsByTagName("body").item(0);

var i, len = d.styleSheets.length;
for(i = 0; i < len; ++i){
var sheet = p.document.createStyleSheet();
sheet.disabled = d.styleSheets[i].disabled;
sheet.cssText = d.styleSheets[i].cssText;
}
var list = create(p.document);

for(i = 0, len = list.menus.length; i < len; ++i){
with({c: menus[i]}){
with(list.menus[i]){
onclick = function(){
c.func();
p.hide();
};
onmouseover = function(){
className += " popup_hover"
}
onmouseout = function(){
className = [" ", className, " "].join("").replace(" popup_hover ", "");
}
}
}
}

popup_html.style.overflow = "hidden";
popup_html.onselectstart = function(){return false};
popup_body.appendChild(list.ele);

p.show(x, y, size.w, size.h + list.menus.length + 1, body);
}

return false;
}


新着レスの表示


名前: E-mail(省略可)

※書き込む際の注意事項はこちら

※画像アップローダーはこちら

(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)

掲示板管理者へ連絡 無料レンタル掲示板