javascript - How to change variable boolean value according to the existence of an asset in the folder? -


i know if there way change value of variable true or false if asset requested in function not in folder.

for example:

ctaurl = "url('initialframes/cta.png')"; nocta = "url('initialframes/nocta.png') no-repeat";   if (ctaurl) {        needcta = true;     cta.style.background = ctaurl; } else {     cta.onerror = function () {     document.getelementbyid(cta).src = nocta;     cta.style.display = "none";     needcta = false;     } }      //           cta.style.width = ctaw + "px"     cta.style.height = ctah + "px"     //     switch(ctahorpos) {         case "left":              cta.style.left = "0px";             cta.style.right = "auto";             break;         case "right":              cta.style.left = "auto";             cta.style.right = "0px";             break;           default:              var ctadistw = (stagew-ctaw)/2             cta.style.left = ""+ctadistw+"px";             cta.style.right = ""+(stagew-ctadistw)+"px";            break;     }     //     cta.style.top = (ctavertpos == "top")?"0px":"auto";     cta.style.bottom = (ctavertpos == "bottom")?"0px":"auto";     //     if (extractafadein) {         cta.style.opacity = 0         tweenmax.to(cta, transitionlength, {opacity:1, delay:0});     } else {         cta.style.opacity = 1;     } 

in html files have variable called "var needcta = true;". so, if boolean true, function gonna ctaurl value. if ctaurl not existent, turn "var needcta" "false" automatically.

as example above, tried noerror method , didn't work.

any great.

regards,

fernando fas


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -