Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
How to run local HTML file in browser with changing address?

I have a simple piece of HTML like this, stored in hr.html

<html>

<head>
    <title>Heart rate</title>
</head>

<body>
    <form>
        <label for="age">Age: </label>
        <input type="text" id="age" name="age"><br><br>
        <label for="restHR">Resting HR: </label>
        <input type="text" id="restHR" name="restHR"><br><br>

        <input type="submit" value="Submit" onclick="printResult()">
    </form>
    <div id='output'></div>
    <script>
        const calTargetHR = (age, restHR) => {
            let targetHR = (((220 - age) - restHR)) + restHR;
            return targetHR
        }
        const printResult = () => {
            document.getElementById("output").innerHTML = calTargetHR(
                document.getElementById('age').value,
                document.getElementById('restHR').value
            )
        }
    </script>
</body>

</html>

I run it by just double click the file. In the address bar it shows as:

file:///C:/Users/work/hr.html?age=&restHR=

The problem is, if I input some value and press the submit button, it's not showing the result because the path becomes:

file:///C:/Users/c21127478/CM6612%20Web/topic3/work/hr.html?age=3&restHR=4

How do I solve this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can add return false to the end of the onClick statement. This prevents the default HTML5 behavior of a form: W3C The button element

<input type="submit" value="Submit" onclick="printResult();return false">
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda