如何在JavaScript中单击按钮打开弹出窗口?

时间:2013-07-04 04:19:56

标签: javascript popup

我在页面上有一个“添加”按钮,单击添加按钮我需要使用portlet打开另一个jsp的透明弹出窗口。怎么可能..?

    <script>
function createXMLHttpRequestObject() {
    var xmlHttp;
    try {
    xmlHttp = new XMLHttpRequest();
    } catch (e) {
    try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHttp");
    } catch (e) {
    }
    }
    if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
    else
    return xmlHttp;
}

var xmlHttp = createXMLHttpRequestObject();
function makeResourceCall(params,call){
    if (xmlHttp){
    try{
        xmlHttp.open("POST", "<portlet:resourceURL/>", false);
    // xmlHttp.onreadystatechange = handleRequestStateChange();
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", params.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.send(params);
        if(call == "componentPopUp"){
        componentDetailsDivFormation(xmlHttp);
        }
        if(call == "ibasePopUp"){
        IbaseDetailsDivFormation(xmlHttp);
     }
        if(call == "scheduleDetailsPopUp"){
        scheduleDetailsDivFormation(xmlHttp);
        }
        }catch (e){
        alert("Can't connect to server:\n" + e.toString());
    }
}
}
</script>        

如何添加此代码,以便在单击按钮时,应该出现透明弹出窗口?

1 个答案:

答案 0 :(得分:0)

window.open("page.html","Page","menubar=no, status=no, scrollbars=no, menubar=no, width=200, height=100");

打开一个弹出窗口: 1.文件 2.窗口的名称 3.选项