javascript - if previous page url with “-cn” ending then change content in current page -


i making site in both english , chinese language, need detect if previous page url "-cn" ending (so know chinese page) change content in current page(default in english). thank you.

code below, sorry i'm new js

$(document).ready(function() {    var referrer =  document.referrer;    //*detect if previous url without "-cn"ending nothing if "-cn" below    //*change content inside "new"<div class="block"></div> });  <div class="block">old</div> 

try one: think want this.

 $(document).ready(function() {        var referrer =  document.referrer;         if(referrer.indexof("-cn")>-1)         {         // referrer url contain "-cn"         }         else         {         // not contain "-cn"         }     }); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -