WebClient a Print button on the UI, press CTRL + P to generate a new page for printing.
As shown in. You can see that all the hyperlinks in this page have been removed.
The generated logic for this page is as follows.
1. Pressing CTRL + P will trigger the WebClient UI frame's key response function Thtmlbkeydown. In the browser's incoming event handler, the CTRL attribute is True,keycode 80 (key p corresponds to code), which means CTRL and P are pressed simultaneously.
This response function Thtmlbkeydown is registered to the entire Document object, so you can get a response if you click Ctrl+p anywhere on the page.
From the upper right-hand corner of the call stack can be found Crmfrwprint is called. The Crmfrwprint will open the Print.do controller, located in the BSP application Bspwd_basics.
2. Open the implementation class for the Print.do controller Cl_bspwd_basics_print
This controller will open the print.html page
3. The content of the page generated after we press Ctrl+p is generated in print.html. In the function ppstartscripts, the core code is registered to the Load event of the page by thtmlbregisteronload, meaning that it executes when the print.html is loaded.
Thtmlutil.addeventhandler is the event registration function that is packaged by SAP itself and is used for compatible support with multiple browsers.
The core of the two functions:
Createshield
Create a div with a height and width of 100%, and set the background image to the SAP pre-defined 1x1.gif.
The runtime is displayed as follows:
LoadPage
The original page with the Ctrl+p key has been window.opener, and the HTML of all the elements below it th-l-wcsubheadercontainer copied directly below the header element of the PrintOut page.
This enables the content of the original page to be moved to the PrintOut page.
Then get all the hyperlink labels for the printed page, and then place the href and onclick of the tags into a function with a function body of return false, so that the hyperlinks are no longer clickable.
var?nirvana?=?new?Function?(?"return?false;"?);
To get more original Jerry's technical articles, please follow the public number "Wang Zixi" or scan the QR code below:
Browser print implementation of CRM WebClient UI