使用jquery打开窗口

时间:2011-07-05 08:25:52

标签: javascript jquery

function openSelectWindow()
{
    var selectScn = document.getElementById("updtGrid:selectScn");
    var selectScnVal = selectScn.value;

    if ((selectScnVal != null) && (selectScnVal != ""))
    {
        var checkedIndex = getCheckedIndex(document);
        var nextActionHref = selectScnVal.toLowerCase() + ".xhtml";

        var jsessionid = document.getElementById("updtGrid:jsessionid").value;

        if (jsessionid != null)
        {
            nextActionHref += (";jsessionid=" + jsessionid);
        }

        nextActionHref += ("?parentScn=azrubbefhs1");
        nextActionHref += ("&mode=UPDATE");
        nextActionHref += ("&remFlt=t");

        if (selectScnVal == "AZRUBXDFHS1")
        {
            var fltFld = document.getElementById("updtGrid:" + "C_Menu");

            if (fltFld == null)
            {
                fltFld = document.getElementById("updtGrid:grid:" + checkedIndex + ":" + "C_Menu");
            }

            if (fltFld != null)
            {
                nextActionHref += ("&parm0=" + fltFld.value);
            }

            nextActionHref += ("&fromFld=Oggetto_procedura")
            nextActionHref += ("&toFld=Sgt_Menu")
            nextActionHref += ("&gridRow=" + checkedIndex);
            nextActionHref += ("&gridAction=AZRUBXDFHS1");
        }

        if (selectScnVal == "AZRUAVDFHS1")
        {
            var fltFld = document.getElementById("updtGrid:" + "C_prodotto");

            if (fltFld == null)
            {
                fltFld = document.getElementById("updtGrid:grid:" + checkedIndex + ":" + "C_prodotto");
            }

            if (fltFld != null)
            {
                nextActionHref += ("&parm0=" + fltFld.value);
            }

            nextActionHref += ("&fromFld=Oggetto_procedura")
            nextActionHref += ("&toFld=C_procedura")
            nextActionHref += ("&gridRow=" + checkedIndex);
            nextActionHref += ("&gridAction=AZRUAVDFHS1");
        }

        wnd = window.open (nextActionHref,selectScnVal,"menubar=0,toolbar=0,scrollbars=yes,resizable=yes,width=500,height=300"); 
        document.getElementById('updtGrid:selectScn').value = "";
    }
}

如何使用jquery打开窗口

2 个答案:

答案 0 :(得分:0)

我真的不明白你的问题,但我想你想用jquery打开一个新窗口。

这是一个示例

你有这个HTML代码

<a href="http://www.google.com/"  rel="0" class="newWindow" >visit Google</a>
<a href="http://www.yahoo.com/" rel="1" class="newWindow" >visit yahoo</a>
<a href="http://www.mysite.com/" rel="2" class="newWindow" >visit my site</a>    

这是脚本

<script type="text/javascript">
    var windowSizeArray = [ "width=200,height=200",
                        "width=300,height=400,scrollbars=yes" ];
    $(document).ready(function(){
        $('.newWindow').click(function (event){
            var url = $(this).attr("href");
            var windowName = "popUp";//$(this).attr("name");
            var windowSize = windowSizeArray[$(this).attr("rel")];

            window.open(url, windowName, windowSize); 
            event.preventDefault();
        });
    });
</script>

编辑:

在加载期间打开一个窗口,你可以这样做

<script type="text/javascript">
    var windowSizeArray = [ "width=200,height=200",
                        "width=300,height=400,scrollbars=yes" ];
    $(document).ready(function(){           
            var url = $(this).attr("href");
            var windowName = "popUp";//$(this).attr("name");
            var windowSize = windowSizeArray[$(this).attr("rel")];

            /// this will open the window
            window.open(url, windowName, windowSize);

    });
</script>

答案 1 :(得分:0)

要打开一个窗口,最好的方法是使用window.open,就像你已经完成的那样