update 1/22/08 : While this method of page detection still works, check out the tutorial Do more with Ka.Info! for a more efficient method.

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 TypeClass(es)
Pre-made Homepageka_homePage
Video, Photo, Audio, and Blog Play Pageska_mediaPlayPage
Video Play Pageka_videoPlayPage
Photo Play Pageka_photoPlayPage
Blog Play Pageka_blogPlayPage
Video, Photo, Blog, Member, and Group List Pageska_searchPage
Video List Pageka_searchvideo
Photo List Pageka_searchphoto
Blog List Pageka_searchblog
Member List Pageka_searchmember
Group List Pageka_searchgroup
Message Board Pageka_messageBoard
Forum Pageka_forum
Discussion Pageka_discussionThread
Group Pageka_clubHome
Profile Pageka_kickPlaceServerSide
Member's "Home" Pageka_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.