Im trying to read a query string from a url and alert a message based on the query string. The strings are being passed on perfectly, I am just haveing trouble reading them on the page. what am i doing wrong?
possible query strings
.../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');
}
});
Two problems: you mistyped location, and you need to toString() it, because location isn’t a string. So the corrected version: