1

为什么 window.location 需要 3 -5 秒才能转到另一页?我想在确认后立即更改页面。

<script>
       var a = confirm('Do you want to insert the device specifications now ؟');
       if(a)
       {
       var name = '<?= $items_name ?>';
       window.location = 'mobiles.php?name='+name;
       }else
       {
       return false;
       }
</script>

在我看来 location.assign 更快

<script> 
var a = confirm('Do you want to insert the device specifications now?');
if(a) {  
  var name = '<?= $items_name ?>'; 
  window.location.assign('mobiles.php?name='+name); 
}
else { 
    return false; 
} 
</script> 
4

1 回答 1

0

Your code will trigger the page change immediately. If you're experiencing a delay, is is most likely the time your browser is taking to load the new page. You can try optimizing the load time for your new page. You can find various resources on the web for page load time optimizations if you simply use Google.

于 2012-05-11T19:09:44.437 回答