Javascript hook causing weird issue with rev slider
<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
we are sorry but in reference to Item Support Policy [Links visible only for registered users], such advanced customization are not included. So if you are not sure about something, you should contact with your web developer.
Thanks for understanding!
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?