我试图从url中读取查询字符串,并根据查询字符串提醒消息。字符串正在完美传递,我只是在阅读页面时遇到麻烦。我究竟做错了什么?jquery从url中获取查询字符串
可能的查询字符串
.../playlist.html?vid=1
.../playlist.html?vid=2
JS
$(function() {
if (window.locaion.search.indexOf('vid=1') > -1) {
alert('1');
} else if (window.locaion.search.indexOf('vid=2') > -1) {
alert('2');
}
});
locaion是一个错字吗? – 2012-02-10 22:46:15
你已经写了'locaion'而不是'location'。在你的运行代码中是否有错字,或者只是在这里的问题? – Rophuine 2012-02-10 22:46:49
错字?尝试位置,而不是你有什么。 – 2012-02-10 22:46:54