JavaScript RegEx for div tags

后端 未结 10 1122
旧巷少年郎
旧巷少年郎 2020-12-17 00:26

I have a JavaScript variable which holds an HTML page and due to the setup I need to extract everything between

and
10条回答
  •  [愿得一人]
    2020-12-17 01:07

    I found this article surfing on the web which take a DIV id and shows it on a new page to print it;

    function getPrint(print_area)
    {
    //Creating new page
    var pp = window.open();
    //Adding HTML opening tag with  …  portion 
    pp.document.writeln('Print Preview')
    pp.document.writeln('')
    pp.document.writeln('')
    pp.document.writeln('')
    
    //Adding Body Tag
    pp.document.writeln('');
    //Adding form Tag
    pp.document.writeln('
    '); //Creating two buttons Print and Close within a HTML table pp.document.writeln('
    '); pp.document.writeln(''); pp.document.writeln(''); pp.document.writeln('
    '); //Writing print area of the calling page pp.document.writeln(document.getElementById(print_area).innerHTML); //Ending Tag of
    , and pp.document.writeln('');

    }

    You will call this script sending the DIV id you want to get;

    btnGet.Attributes.Add("Onclick", "getPrint('YOURDIV');")
    

    It worked exactly as I wanted. Hope it helps

提交回复
热议问题