I. Description
FineReport is a multilingual and cross-platform report designer. Customers often need to use multiple language environments to configure reports.
How to automatically jump to the page of the corresponding language by judging the browser language environment?
II. Example
Create a new template, add a button to cell A1and add a Click event for this button.
The code for the event:
var type = navigator.appName
if (type == "Netscape") {
var lang = navigator.language
} else {
var lang = navigator.userLanguage
}
//Get the first two letters of the browser language
var lang = lang.substr(0, 2)
// Judge English
if (lang == "en") {
window.location.href = "https://www.finereport.com/en/"
// Jump to English url
}
// Judge Japanese
else if (lang == "ja") {
window.location.href = "http://www.finereport.com/jp/"
// Jump to Japanese url
}
// In addition to the languages listed above
else {
window.location.href = "http://www.finereport.com/"
// Jump to urls in other languages
}
The page will automatically recognize the default browser language and jump to the corresponding URL for the language as defined in the code above.
Save the template, and click Pagination Preview to see the effect.