Add printing to identify resuts

From Geomoose

Jump to: navigation, search

You can add a simple print capability to the identify results tab with the followig code. The same function could also be used in the results tab for search or query. Many different scripts can be found for printing on the web. This one worked easily so I used it. To see it work go to Polk Count Oregon WebMap Site and use the identify tool (that is currently in "advanced tools".

Step 1: Create a new print function with the following javascript by pasting this code into the end of your custom.js file (htdocs/extensions/custom.js).

/******************************************************
function printinfodiv
This function will print the countent of the info div that is
typically viewed in the results tab.  By adding a button and a call
to this function from the html used to view results you can print 
outputs easily fromany "div" that has an id. The call from the html is 
typically a button with a call to this function. 
strid - div ID. 
******************************************************/
function printinfodiv(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}

Step 2: Reference the function in your identfy header html (htdocs\php\identify\header.html) with the following HTML code. I put this right after the header text. The html is also referencing a print.png file as the printer icon. Make sure this icon is in the htdocs\images\toolbar directory.

<img src='images/toolbar/printer.png' title='Print' alt='print' onClick="javascript:printinfodiv('information-tab');" Runat="Server" />
Personal tools