
Originally Posted by
RayWilk
On one web page is a word "Select" when clicked on it should open a list
Yet it is dead, when the mouse is over is it reads: javascript:;
Get rid of the "javascript:" part - that's doing you no favours at all.
The standard way to prevent the default behaviour (of following a link) from occurring when you click on one, is to return false from the event.
Code:
<a href="#javascript:;" onClick="select_category(document.getElementById('category_id').value, 'main_category_field', 'main_', false, true, 'wanted'); return false;"><?=GMSG_SELECT;?></a>
A way to further improve on that, is to remove the scripting that is embedded within the HTML content, and move the scripting to the end of the body instead.
This can be easily achieved by giving the link a unique identifier, so that scripting can then more easily access it.
HTML Code:
<a id="select" href="#"><?=GMSG_SELECT;?></a>
Code javascript:
document.getElementById('select').onclick = function () {
select_category(document.getElementById('category_id').value, 'main_category_field', 'main_', false, true, 'wanted');
return false;
}
Bookmarks