我试图替换windows.location ex:
我的Windows位置是http://,我需要在https中替换,此代码返回“ undefinied”值,为什么?
<script>
function myFunction()
{
var windost = window.location;
var opens = windost.replace("http","https");
alert(opens);
}
</script>
最佳答案
尝试这样的事情
function myFunction()
{
var windost = window.location.href;
var opens = windost.replace("http","https");
alert(opens);
}