Calling file.html from a function

0

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

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

    
asked by anonymous 30.05.2018 / 23:20

1 answer

0

Just use window.location to perform the 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.br';
            }
        </script>
    </body>
</html>
    
31.05.2018 / 00:32