<%@LANGUAGE=VBScript%> <%option explicit response.buffer = true response.cachecontrol = "private" response.expires = -1 '--- We don't want this to be cached anywhere '---------------------------------------------------------------------------------------- '- ASP PrinterFriendly application - Version 1.0 - 10 June 2005 '- Copyright © 2005 - Livio Siri (http://www.livio.net) - All Rights Reserved. '---------------------------------------------------------------------------------------- '--- print.asp - Make a link to this page from your page. '--- (ex. Printer friendly) '--- ASSUMES THAT YOUR PAGE HAS PRINTABLE CONTENT WITHIN TWO COMMENTS '--- '--- '--- Needs MSXML 3.0 and VBScript version 5 or above installed '---------------------------------------------------------------------------------------- if request.servervariables("HTTP_REFERER") <> "" then '--- if this didn't come from anywhere, ignore all. '--- Define variables dim strContent, xml_http dim objRegExp, strTitle , strBody, strAns dim content_start, content_end, title_start, title_end dim strThisDir '--- Perform the HTTP "get" method via the XMLHTTP object to retrieve the page to be printed '--- Using the XMLHTTP object instead of something like FSO means that the ASP page '--- is actually executed and not just 'read' as a stream of characters. set xml_http = server.createobject("Microsoft.XMLHTTP") xml_http.open "get", request.servervariables("HTTP_REFERER"), false xml_http.Send strContent = xml_http.responseText set xml_http = nothing '--- get the Referer path for display purpose strThisDir = mid(request.servervariables ("HTTP_REFERER"),1,inStrRev(request.servervariables ("HTTP_REFERER"),"/") ) strBody = strContent '--- strBody contains now the whole HTML page if len(strBody) > 0 then '--- get the page Title to be printed positioning references title_start = instr(lcase(strBody), "") + 7 title_end = instr(lcase(strBody), "") '--- get page Body to be printed positioning references content_start = instr(strBody, "") + 30 content_end = instr(strBody, "") end if '--- Avoid errors if no in the page if len(Title_start) < 1 and len(Title_end) < 1 then strTitle = "No Title" else strTitle = mid(strBody, title_start, title_end - title_start) end if '--- Avoid errors if strBody = nothing or your page doesn't have printable content within two comments if len(content_start) < 1 and len(content_end) < 1 then strBody = "nothing to print" else '--- get the page Body to be printed strBody = mid(strBody, content_start, content_end - content_start) '--- strBody contains now the part of the HTML page to be printed '--- Look for comments <!-- ... --> in the strBody and delete '--- Create built in Regular Expression object set objRegExp = new RegExp objRegExp.IgnoreCase = true objRegExp.global = true objRegExp.Pattern = "<!--(.*?)-->" strAns = objRegExp.replace (strBody, "") strBody = strAns '--- strBody contains now the part of the HTML page to be printed without comments set objRegExp = nothing end if '--- Display the page call display() end if '--------------------------------------------------------- sub display() '--- Prepare and displays the HTML page part to be printed, '--- modify as you need to maintain the same "Style" of your page. %> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <title><%=strTitle%>

Printvenlig Version af "<%=request.servervariables("HTTP_REFERER")%>"
Siden: <%=strTitle%>


<%=strbody%>

<%session.lcid = 1040%>Denne side udskrives fra Bækkelund Gårdbutik, Tranemosevej 8, Ruds Vedby - tlf 5826 1514 - på www.baekkelundgaardbutik.dk <%=date%>
<% end sub %>