| Products | Versions |
|---|---|
| Spotfire | ALL |
When using custom JavaScript in a Text Area, a crash (Internal Error) may occur in the Spotfire Web Player when a user clicks a link or image designed to trigger a script.
This issue is caused by the difference in how the Spotfire Analyst (Desktop) and the Web Player (Browser) handle HTML navigation events.
All
To resolve this, you must prevent the browser's default navigation action when the click event is triggered. You can achieve this in two ways:
Update your JavaScript to accept the event argument and call preventDefault() at the beginning of the function.
Incorrect Code (Causes Crash):
$("#myButton").click(function(){
// Your code here
$("#myInput").val("Test");
});
Corrected Code:
$("#myButton").click(function(event){
event.preventDefault(); // Stops the browser from following the href
// Your code here
$("#myInput").val("Test");
});
Avoid using the <a> (anchor) tag if the element is not actually a link to another page. Instead, use a <span>, <div>, or <button> and style it using CSS to look like a link if necessary. These elements do not have a default navigation behavior.
HTML Example:
<a id="myButton" href="#">Click Here</a>
<span id="myButton" style="cursor:pointer; color:blue;">Click Here</span>
When using custom JavaScript in a Text Area, a crash (Internal Server Error) may occur in the Spotfire Web Player when a user clicks a link or image designed to trigger a script. This issue arises because the Web Player processes the default browser navigation event simultaneously with the custom script.
External: MDN Web Docs: