Home  >  Q&A  >  body text

javascript - 为什么这样编码没效果?

window.location.href=encodeURI("data-search-result.html?a=2&first_level_of_art_classification_cms="+art+"&format="+format+"&first_level_of_subject_classification_cms="+source+"&first_level_of_ethnic_group_cms="+ethnic+"&province_cms="+province+"&city_cms="+city+"&county_cms="+county+"&from_ad_calendar_cms="+from+"&to_ad_calendar_cms="+to+"&")+generalForm;

这是一个跳转链接。。。但是编码后在浏览器上看好像没编过码?

天蓬老师天蓬老师2727 days ago390

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-11 11:38:57

    手册:该方法不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码

    处理的是中文

    encodeURI("你好");
    

    data

    %E4%BD%A0%E5%A5%BD

    reply
    0
  • Cancelreply