开发者

opens window using jquery

开发者 https://www.devze.com 2023-03-17 13:37 出处:网络
function openSelectWindow() { var selectScn = document.getElementById(\"updtGrid:selectScn\"); var selectScnVal = selectScn.value;
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('updt开发者_开发知识库Grid:selectScn').value = "";
    }
}

How to use jquery for opening the window


To open a window the best way is to use window.open , as you have done


I don't really understand your problem but I assume you wanted to open a new window using jquery.

here is a sample

on the html code you have this

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

here is the script

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

EDIT :

to open a window during load you can do this

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

精彩评论

暂无评论...
验证码 换一张
取 消