'프린트'에 해당되는 글 3

  1. 2008.08.26 [ASP] 현재 페이지 인쇄 전용창 처리
IT_Expert/WebProgramming | Posted by 낫기법필 2008. 8. 26. 10:15

[ASP] 현재 페이지 인쇄 전용창 처리


Print this page script

Print
Email
 
VB icon
Submitted on: 11/12/2002 12:13:42 PM
By: Peter Graves 
Level: Beginner
User Rating: By 2 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 31528 times.
 
 
     The code enables you to single out a section of your page for printing by enclosing it in two tags.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:  
By using this code, you agree to the following terms...  
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.  
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.  
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Print this page script
    ' Description:The code enables you to si
    '     ngle out a section of your page for prin
    '     ting by enclosing it in two tags.
    ' By: Peter Graves
    '
    ' Inputs:The URL to the page you want pr
    '     inted
    '
    ' Returns:A nice, printable page
    '
    ' Side Effects:Non that I know of.
    '
    'This code is copyrighted and has
    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=7994&lngWId=4
    'for details.
    '**************************************
    
    <%
    option explicit
    '---------------------------------------
    '     ----------------------------------------
    '     -------
    ' Title : Print This Page Script
    ' Function: To print a section of a page
    '     
    ' In	 : Page URL (?ref=)
    ' Out: Formatted page for prining
    ' By: Peter Graves (ICQ - 116613728)
    '
    ' Example : /print/thisscript.asp?ref=ht
    '     tp://www.myweb.com/mypage.asp
    '
    ' Notes : Could probably be improved, bu
    '     t for now it works
    '
    ' To use : In your documents that you wa
    '     nt to print wrap the content in
    ' <sp> and </sp>
    '---------------------------------------
    '     ----------------------------------------
    '     -------
    Dim RefPage, objXMLHTTP, HTMLPage
    RefPage = Request.QueryString("ref")
    if Len(RefPage) = 0 or Not Left(RefPage,7) = "http://" Then
    	response.write "<H1>Invalid reference page - " & RefPage & "</H1>"
    	response.end
    End if
    Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
    	objXMLHTTP.Open "GET", RefPage, False
    	objXMLHTTP.Send
    	HTMLPage = objXMLHTTP.responseText
    Set objXMLHTTP = Nothing
    %>
    <HTML>
    <HEAD>
    <TITLE><%=GetPageTitle(HTMLPage)%></TITLE>
    <LInk href="/include/style.css" rel="stylesheet" type="text/css">
    </HEAD>
    <BODY onLoad="JavaScript:print();">
    <%=GetPageBody(HTMLPage)%>
    <%=RefPage%>
    </BODY>
    </HTML>
    <%
    function GetPageBody(HTMLstring)
    Dim tag1, tag2, temp1, temp2
    tag1 = "<sp>"
    tag2 = "</sp>"
    temp1 = Split(HTMLstring,tag1)
    if Not uBound(temp1) = 1 Then
    	Response.Write "An Error Occured - please notify the webmaster about this page - " & RefPage
    	response.end
    End if
    temp2 = Split(temp1(1),tag2)
    if Not uBound(temp2) = 1 Then
    	Response.Write "An Error Occured - please notify the webmaster about this page - " & RefPage
    	response.end	
    End if
    GetPageBody = temp2(0)
    End function
    function GetPageTitle(HTMLstring)
    Dim tag1, tag2, temp1, temp2
    tag1 = "<TITLE>"
    tag2 = "</TITLE>"
    temp1 = split (HTMLstring, tag1)
    temp2 = split (temp1(1), tag2)
    GetPageTitle = temp2(0)
    End function
    %>


[출처] http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7994&lngWId=4