Place event button to access page

1

How do I put event button to access the following page:

No Html:

<a id="navMn">Blog</a>

I have the following javascript code, which is in error:

function abreOjnl(){
    window.open('../menu/blog.html');
}

document.getElementById('navMn').addEventListener('click', abreOjnl);
    
asked by anonymous 22.10.2018 / 23:02

2 answers

4

Why do not you use <a href="../menu/blog.html" id="navMn">Blog</a> ?

    
23.10.2018 / 02:22
1

The problem is that you are trying to open a new window of navegador without passing a URL as a parameter.

The way you are using it is not possible because the function will not understand the requested path.

Try this:

window.open('http://seuhost.com/menu/blog.html')

If it's local:

window.open('http://127.0.0.1:porta/menu/blog.html')
    
22.10.2018 / 23:35