js实现局部打印,并处理浏览器提示Avoid using document.write()导致无法打印问题

1 篇文章 0 订阅

如果使用doucment.write()来写入数据Edge会提示下侧问题,谷歌火狐测试无影响!

 

  const iframe = document.createElement('iframe');
        let doc = null;
        //添加属性
        iframe.setAttribute('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
        //插入
        document.body.appendChild(iframe)
        doc = iframe.contentWindow.document;

        //创建div标签 插入到iframe中  
        //处理使用document.write()产出的浏览器提示避免使用的问题
        const conDiv = document.createElement('div');
        conDiv.innerHTML = res['data']
        doc.body.appendChild(conDiv)

        //关闭open()方法打开的文档流。
        doc.close();
        // 获取iframe的焦点,从iframe开始打印
        iframe.contentWindow.focus();
        //打印
        iframe.contentWindow.print();

        setTimeout(()=>{
            document.body.removeChild(iframe);
        },10000)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
IEEE ACCESS模板,双栏,word格式, ABSTRACT These instructions give you guidelines for preparing papers for IEEE Access. Use this document as a template if you are using Microsoft Word 6.0 or later. Otherwise, use this document as an instruction set. The electronic file of your paper will be formatted further at IEEE. Paper titles should be written in uppercase and lowercase letters, not all uppercase. Avoid writing long formulas with subscripts in the title; short formulas that identify the elements are fine (e.g., “Nd–Fe–B”). Do not write “(Invited)” in the title. Full names of authors are preferred in the author field, but are not required. Put a space between authors’ initials. The abstract must be a concise yet comprehensive reflection of what is in your article. In particular, the abstract must be self-contained, without abbreviations, footnotes, or references. It should be a microcosm of the full article. The abstract must be between 150–250 words. Be sure that you adhere to these limits; otherwise, you will need to edit your abstract accordingly. The abstract must be written as one paragraph, and should not contain displayed mathematical equations or tabular material. The abstract should include three or four different keywords or phrases, as this will help readers to find it. It is important to avoid over-repetition of such phrases as this can result in a page being rejected by search engines. Ensure that your abstract reads well and is grammatically correct
First A. Author1, Fellow, IEEE, Second B. Author2, and Third C. Author, Jr.3, Member, IEEE 1National Institute of Standards and Technology, Boulder, CO 80305 USA 2Department of Physics, Colorado State University, Fort Collins, CO 80523 USA 3Electrical Engineering Department, University of Colorado, Boulder, CO 80309 USA Corresponding author: First A. Author (e-mail: author@ boulder.nist.gov). This paragraph of the first footnote will contain support information, including sponsor and financial support acknowledgment. For example, “This work was supported in part by the U.S. Depart¬ment of Com¬merce under Grant BS123456.” ABSTRACT These instructions give you guidelines for preparing papers for IEEE Access. Use this document as a template if you are using Microsoft Word 6.0 or later. Otherwise, use this document as an instruction set. The electronic file of your paper will be formatted further at IEEE. Paper titles should be written in uppercase and lowercase letters, not all uppercase. Avoid writing long formulas with subscripts in the title; short formulas that identify the elements are fine (e.g., “Nd–Fe–B”). Do not write “(Invited)” in the title. Full names of authors are preferred in the author field, but are not required. Put a space between authors’ initials. The abstract must be a concise yet comprehensive reflection of what is in your article. In particular, the abstract must be self-contained, without abbreviations, footnotes, or references. It should be a microcosm of the full article. The abstract must be between 150–250 words. Be sure that you adhere to these limits; otherwise, you will need to edit your abstract accordingly. The abstract must be written as one paragraph, and should not contain displayed mathematical equations or tabular material. The abstract should include three or four different keywords or phrases, as this will help readers to find it. It is important to avoid over-repetition of such phrases as this can result in a page being rejected by search engines. Ensure that your abstract reads well and is grammatically correct. INDEX TERMS Enter key words or phrases in alphabetical order, separated by commas. For a list of suggested keywords, send a blank e-mail to [email protected] or visit http://www.ieee.org/organizations/ pubs/ani_prod/keywrd98.txt

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值