Calling.html file from a function

Asked

Viewed 166 times

0

The most common is that links to other html files are made through the tag <a href>, however, how would I call a.html file from within a javascript function? That is, the user clicks on the link whose event onclick is pointing to any function and within that function I would make the call to the file . html.

The common thing is that we do <a href="anyhtmlfile.html">Clickme</a>

  • 1

    What would be the benefit for such a method?

1 answer

1

Just use window.Location to redirect.

<!DOCTYPE html>
<html>
    <head>
        <title></title>
    </head>
    <body>
        <a href="#" onclick="redirecionar()">Clickme</a>
        <script type="text/javascript">
            function redirecionar() {
                window.location = 'http://google.com';
            }
        </script>
    </body>
</html>

Browser other questions tagged

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