Date Posted:
Product: TIBCO Spotfire®
Product: TIBCO Spotfire®
Problem:
Anchor links do not work in Text areas in TIBCO Spotfire web clients
Solution:
From TIBCO Spotfire version 7.13, anchor links/html bookmarks (#localref) used in Text Areas no longer work (resulting in 404 errors). This is affecting HTML and JavaScript in the text area, including JQuery.
In Spotfire 7.12 and lower (and also later versions of Analyst) the following html works, but in Web Player 7.13 and higher it does not:
<h2 id="top">Header</h2> ...lots and lots and lots of text... <a href="#top">Jump</a>
Since the base URL is different in 7.13 and higher, the last link will jump to <base url>#top and that is a non existing page, resulting in a 404 error from the Server.
The document URL might differ, and also depends on where the file is saved, so the known workaround is to dynamically run a JavaScript to update the href links to include the document URL. This requires that it's possible to run JavaScript on the Web Player (i.e. not applicable to TIBCO Cloud Spotfire).
jQuery sometimes use those local anchor links (ie tabs/#tabs), and will fail if not using the workaround explained above.
The following JavaScript is a possible workaround. It is updating the href links.
// This script looks for "#" in the href tag and replaces all of them with "<documentURL>#"
$('.sfc-text-area a[href^="#"]').each(function(n, e) {
var current = $(e).attr('href')
$(e).attr('href', document.location.href.split('#')[0] + current)
})
Comments
0 comments
Article is closed for comments.