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

90
Vistas
Checking Visited Websites with javascripts

Hello I am walking through the code which check if a user has visited websites before. and the code is as follows

<html>
    <body>
    <H1> Visited </H1>
    <ul id = "visited"></ul>
    <H1> Not visited</H1>
    <ul id ="notvisited"></ul>
        <script>
            var websites =[        
        "http://www.facebook.com",
        "http://www.instagram.com",
        "http://google.com",
        "http://twitter.com"
];
    for( var i = 0; i < websites.length; i++)
    {
        var link = document.createElement("a");
        var linebreak = document.createElement("br")
        link.href = websites[i]
        link.id = "id" + i  
        link.innerHTML = websites[i] + "&nbsp;" 
        document.write("<style>")
        document.write("#id" + i + ":visited{ color: #FF0000; }");
        document.write("</style>")
        document.body.appendChild(link) 
        document.body.appendChild(linebreak)
        var color = document.defaultView.getComputedStyle(link,null).getPropertyValue("color");
        document.write(color)
        document.body.appendChild(linebreak)
        if (color == "rgb(255, 0, 0)"){
        var item = document.createElement('li');
        item.appendChild(link);
        document.getElementById('visited').appendChild(item);

        }
         else {
        var item = document.createElement('li');
        item.appendChild(link);
        document.getElementbyId('notvisited').appendChild(item);
        }    
             }
        </script>
    </body>
</html>

When I check the colors of at the browser. it has changed visually but it has not change at document.write(color) showing rgb(0,0,238) still. So, the problem I am facing and question would like to ask are is as follow :

  1. Why does color does not change in value showing rgb(0,0,238) at document.write() although it changed visually?
  2. 'else' is not seemed to working here unless I replaced it with if (color == rgb(0,0,238) so why it happened there?

so please kindly help me the above problem. Many thanks in advance

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

0

Checking the color of :visited in JavaScript has been a security/privacy vulnerability that was closed long ago. That is why the underlying values have not changed.

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