Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!