K
kelvlam
Hello,
I'm a new begininer with JavaScript. I'm trying to figure out which is
the best approach, and to understand the differences between them.
I have a <A> element that's suppose to either launch a popup window, or
it will link you to some dynamic created page.
I have declared a global JavaScript function
function showStatus(sMsg)
{
window.status = sMsg ;
return true ;
}
I know there are 3 ways to create this <A> tag
Option 1)
<a id="element1" href="#"
onClick="launchLink(this)"
onMouseOut="return showStatus('')"
onMouseOver="return showStatus('{$positions}')">
This option seem to be the simpliest. But if say I scrolled to the
middle of a page, click the link, the entire page will jump to top.
This kind of page-juggling is undesirable.
Option 2)
<a id="element1" href="javascript:launchLink(this)"
onMouseOut="return showStatus('')"
onMouseOver="return showStatus('{$positions}')">
This seem to work fine, but some like the "this" that I pass into the
javascript function, isn't the same as the "this" in option 1. I seem
to have a difficult problem manipulating the element inside the
JavaScript and DOM.
Option 3)
<a id="element1" href="javascript:void(0)"
onClick="launchLink(this)"
onMouseOut="return showStatus('')"
onMouseOver="return showStatus('{$positions}')">
This seem to yield the same result as option, but without the page
juggling. The "this" passed into the javascript seem to behave the
same as option 1 also. So far this is my pick.
Can some JavaScript expert and Guru shed some light to this newbie
please?
Much appreciated for any pointer or advice.
I'm a new begininer with JavaScript. I'm trying to figure out which is
the best approach, and to understand the differences between them.
I have a <A> element that's suppose to either launch a popup window, or
it will link you to some dynamic created page.
I have declared a global JavaScript function
function showStatus(sMsg)
{
window.status = sMsg ;
return true ;
}
I know there are 3 ways to create this <A> tag
Option 1)
<a id="element1" href="#"
onClick="launchLink(this)"
onMouseOut="return showStatus('')"
onMouseOver="return showStatus('{$positions}')">
This option seem to be the simpliest. But if say I scrolled to the
middle of a page, click the link, the entire page will jump to top.
This kind of page-juggling is undesirable.
Option 2)
<a id="element1" href="javascript:launchLink(this)"
onMouseOut="return showStatus('')"
onMouseOver="return showStatus('{$positions}')">
This seem to work fine, but some like the "this" that I pass into the
javascript function, isn't the same as the "this" in option 1. I seem
to have a difficult problem manipulating the element inside the
JavaScript and DOM.
Option 3)
<a id="element1" href="javascript:void(0)"
onClick="launchLink(this)"
onMouseOut="return showStatus('')"
onMouseOver="return showStatus('{$positions}')">
This seem to yield the same result as option, but without the page
juggling. The "this" passed into the javascript seem to behave the
same as option 1 also. So far this is my pick.
Can some JavaScript expert and Guru shed some light to this newbie
please?
Much appreciated for any pointer or advice.