Forum:Preventing a script from showing up on all pages

I have a script that Prepends a link on the top of every page. Is there a way to prevent it from showing up on pages with certain prefixes, such as Files or Templates?-- G i o k u talkuser 16:10, February 2, 2012 (UTC)


 * Of course. Assuming you're talking about javascript, you can use the following:

 if ( wgCanonicalNamespace != File && wgCanonicalNamespace != Template ) {

YOUR CODE HERE

}
 * You may need to include namespaces such as File_talk and Template_talk as well.
 * I think easier would be to make it show up only on the main space... what is the ID for that, just MainSpace?-- G i o k u talkuser 16:47, February 2, 2012 (UTC)
 * Try:

 if ( wgIsMainPage == "true" ) {

YOUR CODE HERE

}
 * No, I want pages in the Main Space, i.e., pages with no prefix. I think this should work:
 * No, I want pages in the Main Space, i.e., pages with no prefix. I think this should work:

if ( wgCanonicalNamespace == Main ) { /*code*/ } -- G i o k u talkuser 16:56, February 2, 2012 (UTC)
 * Aye, that'll work. Sorry for the confusion.