Many clients have requested the ability to display a custom message on saved links when a search returns zero listings.
There is currently an enhancement request to add this functionality directly within the IDX Dashboard and widgets. In the meantime, you can accomplish this with a small amount of custom JavaScript.
How It Works
When a results page returns no listings, IDX Broker displays an element with the following ID:
#IDX-noResultsMessage
You can target this element with JavaScript and replace the default message with your own custom content.
Finding Tags and Classes
You can inspect page elements using your browser developer tools:
https://developers.idxbroker.com/lesson/developer-tools/
Example JavaScript
Add the following script to your website:
<script>
var searchResults = document.getElementById('IDX-noResultsMessage');
if (searchResults !== null)
{
document.getElementById('IDX-noResultsMessage').innerHTML = 'Add your custom message here';
}
</script>
Notes
- This script should be added in the website footer or configured to run after the page has fully loaded.
- The
#IDX-noResultsMessageelement must already exist in the DOM before the script executes. - This solution works on all IDX Broker results templates.
- You can customize the replacement message with text, HTML, links, buttons, or other content as needed.