Javascript hook causing weird issue with rev slider

I have a rev slider on my main page which works perfect. And i am using a the following javascript in a hook (mfn_hook_content_after) to change all the works in the page that have [city] and [contact]

<script>

function qs(key) {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars[key];
}

function phoneFormat(phone) {
  phone = phone.replace(/[^0-9]/g, '');
  phone = phone.replace(/(\d{3})(\d{3})(\d{4})/, "$1-$2-$3");
  return phone;
}


var city = qs('city');
var contact = qs('contact');
var phone = phoneFormat(contact);



window.onload = function() {
 
 document.body.innerHTML = document.body.innerHTML.replace(/\[city\]/g, city);
 document.body.innerHTML = document.body.innerHTML.replace(/\[contact\]/g, phone);

};
</script>


Now when i go to the following url, which would be something like this: www.test.com?city=chicago&contact=8888888888

It changes everything in the page correctly but then the slider stops working for some reason but if i go to the url like this it works fine

www.test.com?city=chicago

It seems like if i use 2 url variables it causes the slider to crash or something not sure. I've been working on this for the last 2 days and can't figure it out. Can some one please help me with this?

Comments

  • Hey,

    we are sorry but in reference to Item Support Policy, such advanced customization are not included. So if you are not sure about something, you should contact with your web developer.

    Thanks for understanding!
  • I'm a little confused on the matter, this is really not advanced customization. It seems to be bug or something weird going on, i have tried this exact code on a different theme and works perfect, no issues whatsoever. And to be honest, one of my friends loves your theme and told me that i need to start using it because your support is very good and that's why i bought it.
  • We understand everything, however, like we wrote above, files customization are not allowed. And this is what you ask for. Please also notice, that we can not be responsible for Revolution Slider plugin because this tool does not belong to us.
  • I agree that file customization is not allowed, and i did not modify any files. I used the betheme options -> Global -> hooks and added it there. And i understand revolution slider plugin does not belong to you but the theme does, and this same code seems to work fine on other themes that use revolution slider as well.
  • I'm just asking for some assistance in troubleshooting the issue, maybe even trying to help me find what is causing it. I usually don't buy themes that my friends recommend unless i have tested them out first. But someone i trust spoke very highly of this theme and support, and to be honest it doesn't seem like you are very willing to help a new customer who just purchased your theme and is asking for some help.
  • Not sure if this helps, but i figured out this piece of code is causing the issue:

    window.onload = function() {
     
     document.body.innerHTML = document.body.innerHTML.replace(/\[city\]/g, city);
     document.body.innerHTML = document.body.innerHTML.replace(/\[contact\]/g, phone);

    };


    Is there anything in the theme that would conflict with that?
  • No, to be honest we don't know if there is anything what might conflict with this.
Sign In or Register to comment.