Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery抓取DIV的内容并在弹出页面中显示,这不仅仅适用于IE。为什么?_Jquery_.net - Fatal编程技术网

Jquery抓取DIV的内容并在弹出页面中显示,这不仅仅适用于IE。为什么?

Jquery抓取DIV的内容并在弹出页面中显示,这不仅仅适用于IE。为什么?,jquery,.net,Jquery,.net,我的网页上有一个打印图标。单击图标,我打开一个弹出页面“Print_content.aspx” 我将查询字符串传递到弹出页面?print=父页面的URL和要获取父页面“#subcent”的DIV的名称,并将DIV subcent(父页面)内的内容加载到弹出页面中的DIV siteloader 这与Mozilla和Chrome完美配合。但不是和我一起 弹出页面中的Jquery: var value=window.location.search; $(文档).ready(函数(){ $(“#sit

我的网页上有一个打印图标。单击图标,我打开一个弹出页面“Print_content.aspx”

我将查询字符串传递到弹出页面?print=父页面的URL和要获取父页面“#subcent”的DIV的名称,并将DIV subcent(父页面)内的内容加载到弹出页面中的DIV siteloader

这与Mozilla和Chrome完美配合。但不是和我一起

弹出页面中的Jquery:

var value=window.location.search;
$(文档).ready(函数(){
$(“#siteloader”).load(value.replace(“?print=“,”)+“#subcent”);
});  
Print_content.aspx的整个标记

    <script type="text/javascript" src="../Scripts/jquery-1.7.2.min.js"></script>

    <link href="../print.css" rel="stylesheet" type="text/css" />
    <title></title>
</head>
<body> 
    <table>
        <tr>
            <td>
                <div id="logo">
                </div>
            </td>
        </tr>
        <tr>
            <td align="center">
                <a runat="server" id="img_Print" onclick="window.print()">
                    <img id="Img1" runat="server" src="/image/btn_print.gif" /></a>

            </td>
        </tr>
        <tr>
        <td align="left">
          <div id="siteloader">
                </div>
        </td>
        </tr>
    </table>


    <script type="text/javascript">

        var value = window.location.search;   
        $(document).ready(function () {
            $("#siteloader").load(value.replace("?print=", "") + " #subcontent");
        });  
    </script>  

   <div id="div-overlay" style="position: absolute; top:130px; height: 100%; width: 100%; z-index: 200;  opacity: 0.0;background-color:Gray;"> </div> 
</body>
</html> 

var值=window.location.search;
$(文档).ready(函数(){
$(“#siteloader”).load(value.replace(“?print=“,”)+“#subcent”);
});  

您是否打算改用
var value=window.location.href

将内容从父页面打印到弹出页面的另一种方式可以是:

$("a.doPrint").click(function(e) {
  e.preventDefault();
  var printSource = $("#myElementToPrint");
  var printWindow = window.open("", "printWindow", "width=700,height=400,location=no,menubar=yes,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no");
  if(!printWindow) alert("Please enable popups to access this feature.");
  else {
    printWindow.onload = function() {
      setTimeout(function() {
        if (printWindow.screenX === 0) {
          alert("Please enable popups to access this feature.");
        }
      }, 0);
    };
    printWindow.document.write('<html><head><title>Printing Page</title></head><body>' + printSource.html() + '</body></html>');
    printWindow.print();
  }
  return false;
});
$(“a.doPrint”)。单击(函数(e){
e、 预防默认值();
var printSource=$(“#myElementToPrint”);
var printWindow=window.open(“,”printWindow“,”宽度=700,高度=400,位置=no,菜单栏=yes,可调整大小=no,滚动条=yes,状态=no,标题栏=no,工具栏=no”);
如果(!printWindow)警报(“请启用弹出窗口以访问此功能”);
否则{
printWindow.onload=函数(){
setTimeout(函数(){
如果(printWindow.screenX==0){
警报(“请启用弹出窗口以访问此功能”);
}
}, 0);
};
printWindow.document.write('Printing Page'+printSource.html()+'');
printWindow.print();
}
返回false;
});

No,window.location.search是在传递了查询字符串值的父页面中搜索div。有两个值通过querystring传递到弹出页面。父页面的名称和要在弹出页面中显示的父页面中的div id获取父页面的div内容后,我将其替换为弹出页面中的div。我的问题是为什么它不能单独用于IE?
窗口。location.search
是GET请求中的
之后的所有内容。例如,“-
window.location.search
将产生”?q=test&hl=en“。。。这本身不是一个有效的URL。尽管如此,也许您可以在请求的页面前面加上
document.referer
,并让它显示
document.referer+值。替换(“?print=“,”)+“#subcent”
用一个示例更新了我的答案。
$("a.doPrint").click(function(e) {
  e.preventDefault();
  var printSource = $("#myElementToPrint");
  var printWindow = window.open("", "printWindow", "width=700,height=400,location=no,menubar=yes,resizable=no,scrollbars=yes,status=no,titlebar=no,toolbar=no");
  if(!printWindow) alert("Please enable popups to access this feature.");
  else {
    printWindow.onload = function() {
      setTimeout(function() {
        if (printWindow.screenX === 0) {
          alert("Please enable popups to access this feature.");
        }
      }, 0);
    };
    printWindow.document.write('<html><head><title>Printing Page</title></head><body>' + printSource.html() + '</body></html>');
    printWindow.print();
  }
  return false;
});