fatheeym Posted January 1, 2017 Share Posted January 1, 2017 i want to add this code in cms page <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> <script> $(document).ready(function (){ if(navigator.userAgent.toLowerCase().indexOf("android") > -1){ window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en'; } if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){ window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8'; } }); </script> and this code can't be in the main js file because it will redirect user to the app for his/her smartphone OS thank you Link to comment Share on other sites More sharing options...
Daresh Posted January 1, 2017 Share Posted January 1, 2017 Try to add additional condition to it, something like: if ($('body').hasClass('cms')) { ... } Link to comment Share on other sites More sharing options...
vekia Posted January 1, 2017 Share Posted January 1, 2017 /themes/your-theme/js/cms.js this file is included only to cms pages. Link to comment Share on other sites More sharing options...
fatheeym Posted January 1, 2017 Author Share Posted January 1, 2017 thank yoy for your replies but thats mean if any customer go to any cms page he will be redirect to app store or play store even if this page was the terms or delivery page i want this code to be only on one cms page not all pages Link to comment Share on other sites More sharing options...
vekia Posted January 2, 2017 Share Posted January 2, 2017 you can add there condition to check what cms page is viewed based on Daresh suggestion, you can use something like: if ($('body').hasClass('cms-3')) { } each cms page has own unique class in <body> tag. 3 in the example above is an ID of terms of conditions page. you can change it to work only on selected page, just replace "3" with ID of target cms page. 2 Link to comment Share on other sites More sharing options...
fatheeym Posted January 2, 2017 Author Share Posted January 2, 2017 thank you for your replay but i'm not a programmer please type the full code Link to comment Share on other sites More sharing options...
vekia Posted January 2, 2017 Share Posted January 2, 2017 code above is full code. you have to identify the ID of CMS page for which you want to enable the script and replace "cms-3" with id of your cms page for example "cms-1" 1 Link to comment Share on other sites More sharing options...
fatheeym Posted January 2, 2017 Author Share Posted January 2, 2017 if ($('body').hasClass('cms-3')) { <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> <script> $(document).ready(function (){ if(navigator.userAgent.toLowerCase().indexOf("android") > -1){ window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en'; } if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){ window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8'; } }); </script> } so the code will be like this Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now