Javascript 使用jquery打开窗口

Javascript 使用jquery打开窗口,javascript,jquery,Javascript,Jquery,如何使用jquery打开窗口我不太理解您的问题,但我假设您想使用jquery打开一个新窗口 这是一个样本 在html代码中,您有以下内容 function openSelectWindow() { var selectScn = document.getElementById("updtGrid:selectScn"); var selectScnVal = selectScn.value; if ((selectScnVal != null) &&am

如何使用jquery打开窗口

我不太理解您的问题,但我假设您想使用jquery打开一个新窗口

这是一个样本

在html代码中,您有以下内容

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 = "";
    }
}
这是剧本

<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>

打开一个窗口最好的方法是使用window.open,正如你所做的那样

我认为你需要编写一个插件。你有问题吗?你的问题不清楚。也许你的意思是:是的,我想用jquery打开一个新窗口,但实际上我不想单击任何链接或按钮。在窗口加载事件中调用函数openSelectWindow。这样地
<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>