Javascript URL window location works on Chrome but fail on Firefox


This is commmon things that happen when we’re using “window.location.origin” to define the path for AJAX call or another purpose.
Actually, “window.location.origin” isn’t in browser standard. Firefox try the best to obey the standard which “window.location.origin” is not supported hence it give “undefined” result.

Substitution for this, you can use:

1
window.location.protocol + "//" + window.location.host

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.