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

92
Views
Comprobación de sitios web visitados con javascripts

Hola, estoy revisando el código que verifica si un usuario ha visitado sitios web antes. y el codigo es el siguiente

 <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>

Cuando compruebo los colores de en el navegador. ha cambiado visualmente pero no ha cambiado en document.write(color) mostrando rgb(0,0,238) todavía. Entonces, el problema al que me enfrento y la pregunta que me gustaría hacer es la siguiente:

  1. ¿Por qué el color no cambia de valor mostrando rgb(0,0,238) en document.write() aunque cambió visualmente?
  2. Parece que 'else' no funciona aquí a menos que lo reemplace con if (color == rgb (0,0,238), entonces, ¿por qué sucedió allí?

así que por favor amablemente ayúdame con el problema anterior. Muchas gracias de antemano

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Verificar el color de :visited en JavaScript ha sido una vulnerabilidad de seguridad/privacidad que se cerró hace mucho tiempo. Es por eso que los valores subyacentes no han cambiado.

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!