I have installed KanjiStrokeOrders font on my machine to show the Kanji stroke order.
Objective
I want to create a web page for my own purpose of learning Japanese. When HTML pages are viewed on the browser, I want to be able to show the stroke order of a single Kanji character being right-clicked via a tooltip with KanjiStrokeOrders
font family and of course with a bigger font size.
My Attempt
The following code is my attempt but it just toggles the font whenever I hover the region bounded by the body
. The result is annoying because,
- the space is dynamically changed so it produces blinking that is not eye-friendly,
- I cannot select just a single character,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script language="JavaScript">
function toggleFont() {
var _font = document.getElementsByTagName('body')[0].style.fontFamily;
if (_font != 'KanjiStrokeOrders') {
document.getElementsByTagName('body')[0].style.fontFamily = 'KanjiStrokeOrders';
document.getElementsByTagName('body')[0].style.fontSize = '120px';
}
else {
document.getElementsByTagName('body')[0].style.fontFamily = 'Arial';
document.getElementsByTagName('body')[0].style.fontSize = '12pt'; // return to the normal font
}
}
</script>
</head>
<body onmouseover="toggleFont();" onmouseout="toggleFont();">
僕は合気道が好きだ。I love Aikido.
</body>
</html>
Questions
How to show a tooltip with KanjiStrokeOrders
font whenever a single character is right-clicked and the tooltips vanishes when the mouse is released?