posted on August 23

The following code will modify all electronic file links, such as PDF documents, to open using ElectronicFile.aspx instead of DocView.aspx in Laserfiche WebLink 11.x

1. Open Browse.aspx in a text editor, copy the code below and paste it right above the </body> element.

(function() {

    var proxied = window.XMLHttpRequest.prototype.send;
	var sent = false;
    window.XMLHttpRequest.prototype.send = function() {
		sent = true;
        var pointer = this
        var intervalId = window.setInterval(function(){
			console.log('Ready State: ' + pointer.readyState);
                if(pointer.readyState != 4){
				sent = false;			

        }, 1);
        return proxied.apply(this, [];
	// After initial load, observe the table that contains the links for any additions due to scrolling
	var t = document.getElementsByClassName('p-datatable-table')[0];
	var observer = new MutationObserver(entryname_column_changes);
	observer.observe(t, {
		attributes: false,
		childList: true, // report added/removed nodes
		subtree: true,   // observe any descendant elements


function entryname_column_changes(mutations){
  for (let mutation of mutations) {
    if (mutation.type === 'childList') {

function transform_links() {

    //Obtain the EntryNameColumn cells in the browse table and loop through them after a slight delay
    $(".EntryNameColumn").delay(500).each(function () {
        // Find all A elements
		$(this).find("a").each(function() {
			// Get all a elements that have a class value of ElectronicFileIcon
			var ef = $(this).find("div.ElectronicFileIcon");
			// console.log($(this).attr("href"));
			// console.log(ef.length);
			if(ef.length == 1){
				// Get the existing URL
				var old_url = $(this).attr("href");
				// Transform links that have not already been processed
					// Create a new URL based upon the old one
					var new_url = old_url.replace("DocView","ElectronicFile").replace("?id=","?docid=");
					// Replace old URL with our new one
					// Clone the content which removes all existing event handlers
					var b = $(this).clone();
					// Replace existing content with the clone content which will allow the ElectronicFile link to work.

2. Save browse.aspx and refresh the page. All of the electronic file links should now open directly.

Hope this helps!

Wesley Funderberg

5 0