使用Javascript在IE中打开多个窗口? [英] Open multiple windows in IE using Javascript??

查看:89
本文介绍了使用Javascript在IE中打开多个窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想要做的是 - 我有一个网格视图,并且每个行中都有复选框和指向另一个表单的超链接。我需要选中多个复选框并点击"打印"按钮。它应该打印所有表单(通过超链接链接)与相同的URL但不同的
参数。


问题是我编写的代码工作正常但有时它表现得很好不确定。当我检查几个复选框时,让我们说5;打开5个新窗口,但有时同一个窗口加载了新的url,打印命令仅适用于3个窗口
并且跳过其他两个被覆盖的窗口。



函数PrintForm(dataGridView)  {


    var objSearch = document.getElementById(dataGridView);


    var ControlId ='';


    var txtAppend ='';


    var hidReqid ='';


    var txtReqId ='';


    if(objSearch){ 


          var objSearchRows = objSearch.rows.length;    }


    //循环通过网格行并检查选中的复选框


  &NBSP; for(var rowCount = 2; rowCount< objSearchRows + 1; rowCount ++)  &NBSP; {


  &NBSP; &NBSP; &NBSP; if(rowCount< 10){


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; txtAppend ='_ ct0';  &NBSP; }


  &NBSP; &NBSP; &NBSP;否则{


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; txtAppend ='_ ctl';  &NBSP; &NBSP; }


  &NBSP; &NBSP; &NBSP; ControlId = objSearch.id + txtAppend + rowCount +'_ chkSelect';


  &NBSP; &NBSP; &NBSP; ControlId = document.getElementById(ControlId);


   &NBSP; &NBSP; &NBSP; if(ControlId){


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(ControlId.checked == true){


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; hidReqid = objSearch.id + txtAppend + rowCount +'_ hidRqstId';


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; txtReqId = document.getElementById(hidReqid).value;


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; var mywindow = window.open('PrintForm.aspx?RqstId ='+ txtReqId,'RequestForm'+ txtReqId," toolbar = no,resizable = yes,scrollbars = yes,menubar = no,location = no,height = 30, width = 30");


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; window.focus();


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; mywindow.print();


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; mywindow.close();


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }


  &NBSP; &NBSP; &NBSP; }


  &NBSP; }


}


解决方案


 


我会尝试在windowname上添加一个时间跨度...


 


'RequestForm'+ txtReqId + timespan


 


 


问候


Hi All,

What i want to do is - I have a grid view and in that there are check box and a hyperlink to another form in each row. I need to select multiple check box and hit on Print Button. It should print all the forms (linked by hyperlink) with same url but different parameters.

Problem is that i have written the code which is working fine but sometimes it behaves very uncertain. When i check few check boxes, let say 5; 5 new windows are opened but sometimes same window is loaded with new url and print command comes only for 3 windows and skips for the other two overridden.

function PrintForm(dataGridView)  {

    var objSearch = document.getElementById(dataGridView);

    var ControlId = '';

    var txtAppend = '';

    var hidReqid = '';

    var txtReqId = '';

    if(objSearch) {  

          var objSearchRows = objSearch.rows.length;    }

    //Loop thru the grid rows and check for the checked checkboxes

    for ( var rowCount = 2; rowCount < objSearchRows + 1; rowCount++ )    {

        if(rowCount < 10) {

            txtAppend = '_ctl0';    }

        else {

            txtAppend = '_ctl';      }

        ControlId = objSearch.id + txtAppend + rowCount + '_chkSelect';

        ControlId = document.getElementById(ControlId);

         if(ControlId) {

            if(ControlId.checked == true) {

                hidReqid = objSearch.id + txtAppend + rowCount + '_hidRqstId';

                txtReqId = document.getElementById(hidReqid).value;

                var mywindow = window.open('PrintForm.aspx?RqstId='+txtReqId,'RequestForm'+txtReqId,"toolbar=no,resizable=yes, scrollbars=yes,menubar=no, location=no, height=30, width=30");

                window.focus();

                mywindow.print();

                mywindow.close();

            }

        }

    }

}

解决方案

hi,

 

i would try adding a timespan to the windowname...

 

'RequestForm'+txtReqId + timespan

 

 

greetings.


这篇关于使用Javascript在IE中打开多个窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆