CODE
<script>
window.location.href = 'SomeSite.php'; // THIS WORKS
var x = window.location.href; // THIS DOES NOT!
alert("X : ",x); // Shows X :
</script>
I have no function or Anything. I just run this Script Code in my HTML File and it used to work for Months. I have no idea why it isn't working right now. How is it that Im able to redirect the page using window.location.href but not get the current URL?
Instead of alert("X : ",x);
Try using alert("X : " + x);
. This should solve it. When you put a comma inside the alert function, it might consider it as another parameter, so you must concatenate using "+".