I'm checking over my code for uses of == instead of ===, but changing this line:
if(window.location == 'app:/test.html')
To this:
if(window.location === 'app:/test.html')
Results in the block no longer being executed.
What is the correct approach?
The reason for this is because
===matches the type as well as the contents.window.locationacts like astringin most cases, but is actually aLocationobject.You can change your
ifto check thehrefproperty, which is astring:Your code will then work as intended!
MDN has a decent article about
window.locationthat's worth a read.