I was trying to add links into javascript but could not do it. Loober is checking an input box. According to the focus, i wanted to change the links that appear on the page. changeME is default.
开发者_高级运维 <script type = "text/javascript">
var check = document.getElementById("loober");
var testElement = document.getElementById("changeMe");
var text = "bbb";
var text2 = "aaa";
check.onfocus= function()
{
testElement.innerHTML = text.link("index.php");
}
check.onblur = function()
{
testElement.innerHTML = text2.link("home.php");
}
</script>
Thanks
In answer to your second problem, you can set a short timeout to change the link:
check.onblur = function() {
setTimeout( function() {
testElement.innerHTML = text2.link("home.php");
}, 250);
}
The code calls an anonymous function after 250ms that will return the link to the "blur" link. It should give the user enough time for the link's click event to register. You can change 250 to suit your needs after testing.
精彩评论