We need to disable the Hyperlinks in the maps (the 2nd Map option where publicly accessible link is allowed) so that the end-users do not have the ability to click on a sensor.

How can I do this?


Article Comments

Update: As of PRTG version 16.3.26, you can create public maps with disabled links by using the maps settings.

  • In the PRTG web interface, open the Settings tab of the desired map.
  • Navigate to section Public Access.
  • Choose the option Allow public access, disable all links (map can be viewed by using a unique URL).
  • Save the settings and the map will be a non-interactive public map.

For details please see PRTG Manual: Maps Settings—Settings: Public Access.


This article applies to PRTG Network Monitor 12 through 16.3.25

Disabling Links in Public Maps

Important note: As of PRTG version 16.3.26, you can use the settings of a public map to disable its links. Please see above.

The PRTG API can help you with this (requires PRTG 8).

Find the file scripts_custom.js in the \webroot\javascript subfolder of your PRTG installation and open it with a text editor. (Note: In versions previous to PRTG 13.2.3, the target file is customerscripts.js in \website\javascript.)

Paste the following code into the file:

$(document).ready(function() {
  if ($("body.publicmapshow").length>0) // check: is this a mapshow page
  {
    $("a").attr("href", "#").attr("onclick", "return false;");; // disable all links on page, they still look like links
  //OR
  //$("a").each(function(){$(this).replaceWith($(this).text())}); //replaces all links with just their text
  }
});

For previous PRTG versions (Deprecated)

$(document).ready(function()
	
{
  if ($("#maprefreshlink").length>0) // check: is this a mapshow page

	{
		$("a").attr("href", "#"); // disable all links on page, they still look like links

		// OR
		// $("a").each(function(){$(this).replaceWith($(this).text())}); //replaces all links with just their text

	}

});

The code is run everytime a PRTG page is loaded. It checks if the page is displaying a map and then iterates through all <a> tags and overwrites their HREF properties with a "#" to invalidate the links.

If you use a PRTG version newer than V8.4.x, please apply the following patch to the file prtg.js:

$(function() {
    $(".sensorgraph").attr("onclick", "");
    $("#showamap").delegate("a", "click", function(e) {
        e.preventDefault();
    });
});

If you use a PRTG version 13.4.x.x or newer, please apply the following patch to the file scripts_custom.js:

$(function(){
  $("body.publicmapshow").on('click','a',function(){return false;});
});

Note: If you use a PRTG version previous to V8.1.0.1678 you must either update or apply the following patch to the file "prtg.js":

Remove this line (2nd last line of the file)

<#comment Include customer's own Javascript>

Oct, 2010 - Permalink

Sorry, but how can I use PRTG V8.1.0.1678 if newest availiable version now to download now is 8.1.0.1676?!


Oct, 2010 - Permalink

A newer version will be available today.


Oct, 2010 - Permalink

Good news!


Oct, 2010 - Permalink

Hello,

I tried the above solution but the links are still visible. Any ideas? Is it to do with AJAX?

PRTG Network Monitor 8.1.2.1810 Operating System: Windows XP (5.1.1 Build 2600 Service Pack 3), 4 CPUs, Intel Pentium, on "STM3500418AS"

Thanks

Nicholas


Jul, 2011 - Permalink

@nicholasrichardson: The following code may help

$("a").each(function(){$(this).replaceWith($(this).text())}); replaces all links with just their text

I have pasted this into the "best answer" above, too.


Jul, 2011 - Permalink

Is it possible to choose which maps are affected?


Sep, 2011 - Permalink

@MattG: You could edit the script to look into the URL parameters. Each map as a unique "id=" url parameter and trigger your code by that

The if statement in my code shown above would change similar to this:

  if (($("#maprefreshlink").length>0) && (getURLParam("id")="123"))


Sep, 2011 - Permalink

For the latest version 12 add this to the customerscripts.js

$(function() { $(".sensorgraph").attr("onclick", ""); $(".map_linkedobject").attr("onclick", "return false;"); $("#showamap").delegate("a", "click", function(e) { e.preventDefault(); }); });


Oct, 2012 - Permalink

Is there a way to edit that javascript to exclude certain links ? I have a setup with links to other maps. Can I add a "whitelist" section to it ?


Mar, 2014 - Permalink

Sorry, it's only possible to exclude all links.


Mar, 2014 - Permalink

I agree that Read Only maps (with no links) would be useful. I think that only being able to restrict links in all maps is a poor solution.

How about in a next version adding a parameter to the public map link that tells the map whether it is to display read only. eg. &ro=true I'm sure you would make a much better job adding the code into the product properly rather that having users fiddle about in the javascript trying to disable links with 'self modifying' code.


Mar, 2014 - Permalink

I also agree that "true read only" maps would be a very welcome addition. Because I want to publish a few dashboards for "public" use but do not want any way to access PRTG itself from them or even expose the possibility.

Also I cannot get the mentioned solutions to work. I am using PRTG 16.3.24.4980 and have tried these solutions in \webroot\javascript\scripts_custom.js - all links are still available and clickable in public maps. Has this changed again with later versions?


Aug, 2016 - Permalink

Christian, the above listed scripts were outdated. Please try the following one:

$(document).ready(function() {
  if ($("body.publicmapshow").length>0) // check: is this a mapshow page
  {
    $("a").attr("href", "#").attr("onclick", "return false;");; // disable all links on page, they still look like links
  //OR
  //$("a").each(function(){$(this).replaceWith($(this).text())}); //replaces all links with just their text
  }
});

(as of PRTG version 16.2.24/16.3.24)


Aug, 2016 - Permalink

As an update to this thread, we'll introduce a setting to this with version 16.3.26, where you can set this on each map individually.


Sep, 2016 - Permalink

Is there a way to disable the link for one object in the map, only for that object. Or is there a way to change the object to disable the links?


Mar, 2017 - Permalink

Hi there,

Unfortunately, you can only disable the links for the complete map, not just one object.

Best regards.


Mar, 2017 - Permalink