mam pytanie: otóż czy można zrobić tak, aby poniższy skrypt działał, lecz bez pobierania eventu w funkcji item_description?
Kod
...
<script type="text/javascript" language="JavaScript">
var cursorX, cursorY;
function get_cursor_position (event) {
cursorX = event.clientX + document.body.scrollLeft;
cursorY = event.clientY + document.body.scrollTop;
}
function item_description (event, header, text) {
get_cursor_position (event);
document.getElementById ("message").innerHTML = header + '<br><small>' + text + '</small>';
document.getElementById ("message").style.left = (cursorX + 1) + 'px';
document.getElementById ("message").style.top = (cursorY + 1) + 'px';
document.getElementById ("message").style.display = 'block';
this.onmouseout = function (event) {
document.getElementById ("message").style.display = 'none';
}
}
</script>
...
<div id="message"></div>
<img src="items/potion_health.png" class="item" onmousemove="java script:item_description (event, 'Eliksir zdrowia', 'Przywraca 50% punktów życia');">
...
<script type="text/javascript" language="JavaScript">
var cursorX, cursorY;
function get_cursor_position (event) {
cursorX = event.clientX + document.body.scrollLeft;
cursorY = event.clientY + document.body.scrollTop;
}
function item_description (event, header, text) {
get_cursor_position (event);
document.getElementById ("message").innerHTML = header + '<br><small>' + text + '</small>';
document.getElementById ("message").style.left = (cursorX + 1) + 'px';
document.getElementById ("message").style.top = (cursorY + 1) + 'px';
document.getElementById ("message").style.display = 'block';
this.onmouseout = function (event) {
document.getElementById ("message").style.display = 'none';
}
}
</script>
...
<div id="message"></div>
<img src="items/potion_health.png" class="item" onmousemove="java script:item_description (event, 'Eliksir zdrowia', 'Przywraca 50% punktów życia');">
...
Chodzi mi o to, czy zamiast:
Kod
item_description (event, 'Eliksir zdrowia', 'Przywraca 50% punktów życia');
mogłoby być: Kod
item_description ('Eliksir zdrowia', 'Przywraca 50% punktów życia');
(bez event w funkcji).Z góry dziękuję za odpowiedzi,
zavada