i am a newbie to jscript. i have used this code in javascript to return to home page
function gohome()
{
window.location="../index.html"
}
and i am calling that function in this code
'<a accesskey="h" id="home" href="javascript:gohome();">Home<\/a>' +
there will be link on a page when it is clicked it will call gohome() function. but same link is appearing on the index page.when clicked it is showing page not found.
How to make this link hide in index.html page?
Can anyone help me??
Add .href:
function gohome()
{
window.location.href="../index.html"
}
I don't think you need a javascript function to do go home you can just do this:
<a accesskey="h" id="home" href="../index.html">Home<\/a>
if you don't want it to show on the home page though you can do something like this assuming the home page is example.com/index.html
if(window.location.pathname=="/index.html"){
document.getElementById('home').style.display = 'none';
}
Not in the function, but just called sometime after the link in the source code or in the head.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With