Applying JavaScript to Specific Page Types
by Josh
Each KickApps-powered page type has a different class applied to #ka_mainContainer. So to apply JS to a specific page type, all you have to do is figure out the class of the page type that you want to target, and then wrap your JS in an if-statement that makes sure that #ka_mainContainer has this class, like this:
if (document.getElementById('ka_mainContainer').className.indexOf('enter class name') >= 0){
//put your JS here
}
You can use this table to find out the class value for the page type that you want to target:
| Page Type | Class(es) |
| Pre-made Homepage | ka_homePage |
| Video, Photo, Audio, and Blog Play Pages | ka_mediaPlayPage |
| Video Play Page | ka_videoPlayPage |
| Photo Play Page | ka_photoPlayPage |
| Blog Play Page | ka_blogPlayPage |
| Video, Photo, Blog, Member, and Group List Pages | ka_searchPage |
| Video List Page | ka_searchvideo |
| Photo List Page | ka_searchphoto |
| Blog List Page | ka_searchblog |
| Member List Page | ka_searchmember |
| Group List Page | ka_searchgroup |
| Message Board Page | ka_messageBoard |
| Forum Page | ka_forum |
| Discussion Page | ka_discussionThread |
| Group Page | ka_clubHome |
| Profile Page | ka_kickPlaceServerSide |
| Member's "Home" Page | ka_myPlace |
So, for instance, to target video play pages, the code would look like this:
if (document.getElementById('ka_mainContainer').className.indexOf('ka_videoPlayPage') >= 0){
//put your code in here
}
Fill in the JS that you want to apply to video play pages, and you should be good to go. Happy coding!
Did you enjoy this tutorial? Have questions, comments, or want to submit one of your own? Contact us at support@kickapps.com.