Place event button to access page

Asked

Viewed 47 times

2

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

In 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);
  • Leandro, managed to accomplish what he wanted using <a href=" ?

2 answers

3

Why don’t you use the <a href="../menu/blog.html" id="navMn">Blog</a> ?

  • 2

    Using so it becomes much simpler!

2

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 it this way:

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

If it’s local:

window.open('http://127.0.0.1:porta/menu/blog.html')
  • cannot use http, because the directory is in the pc folder and not in the network kk

  • more be able to solve by switching extension to php and open with xxamp https://localhost but still worth it :)

  • @Leandro Lobo managed to solve?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.