Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda