-1

I m trying to match subdirectory and populate the variable according to it. This is what I have done so far.

For example i have a domain (www.mydomain.com/city/).

<script type="text/javascript">
var lnk = "";
if (window.location.href.match("city")) {
   lnk = "aqer123";
   } else if (window.location.href.match("country")) {
       lnk = "aber321";
       }

Then this "lnk" variable should becomes the value of disqus_shortname

var disqus_shortname = 'lnk'; // required: replace example with your forum shortname

/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
    var s = document.createElement('script'); s.async = true;
    s.type = 'text/javascript';
    s.src = '//' + disqus_shortname + '.disqus.com/count.js';
    (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script> 

It is not working. Is there an alternative way of populating variable according to subdomain? Any help would be great.

1 Answers1

0

You are not assigned the value of lnk to disqus_shortname you are assigning it a string 'lnk'.

var disqus_shortname = 'lnk';

Instead pass it the variable.

var disqus_shortname = lnk;
David Barker
  • 14,484
  • 3
  • 48
  • 77