How to check in javascript if url address start with defined string?

javascript

Solution

Just use normal string searching:

// if the url begins with this string
if (window.location.href.indexOf('http://www.odsavacky.cz/blog/wpcproduct/') == 0) {
    // Do what you want
}

Problem

Is it possible to check if a url address starts with for example: http://www.odsavacky.cz/blog/wpcproduct/ ?

Original source