javascript - Why isn't my function called after DOMContentLoaded? -
ive created jfiddle demonstrate: https://jsfiddle.net/t5lgwvzg/5/
i have function changes colours of few svg polygons i've made. when run locally chrome/firefox, colours load expected. when run internet explorer/jsfiddle polygons remain white they're original colour. question why isn't working? i've spent hours trying figure out . . .
here's function:
function statcolor() { var random; document.getelementbyid("print").innerhtml = "enter"; (var = 0; < counties.length; i++) { random = (math.random() * 100); elem = document.getelementbyid(counties[i]); if (random >= 0 && random <= 25) { elem.style.fill = "green"; } else if (random > 25 && random <= 50) { elem.style.fill = "yellow"; } else if (random > 50 && random <= 75) { elem.style.fill = "orange"; } else if (random > 75 && random <= 100) { elem.style.fill = "red"; } } document.getelementbyid("polynorthernireland").style.fill = "grey"; } and should called:
document.addeventlistener("domcontentloaded", statcolor, false); should have mentioned i'm using ie11
use attachevent() , addeventlistener() doesn't work on ie less 9.0
Comments
Post a Comment