Multi
Multi
Simply put: Page-specific scripts
Topic Started: Thursday, 7. July 2011, 14:06 (318 Views)
Joe
Member Avatar
Hi.
This snippet will make a script run only on a certain page. [bbc_code]if (location.href.indexOf('/index') !== -1) {
alert('Omg, an index-only code!');
}[/bbc_code] * Page that you want it to run on. Use `/index` instead of `/index/` because ZetaBoards loads both of those. `/index` covers both, `/index/` does not!

Hm, how about multiple pages? This is the most common way of doing it - just use the `or` operator, which is `||` . [bbc_code]if (location.href.indexOf('/index') !== -1 || location.href.indexOf('/members') !== -1) {
alert('Omg, an index-only and members-page only code!');
}[/bbc_code]
Joe
Off
Profile
Quote
Top
 
Oracle
Member Avatar
Level 8
May I ask why do you put the '!== -1'?
Visit my shop! Forum reviews, posting packages, recolors
Posted ImagePosted Image
Posted Image
Me!

Off
Profile
Quote
Top
 
Aidan
Member Avatar
Level 12
Outline Documentations
T H E M E S

Documentation accepted in to the Themes database
Off
Profile
Quote
Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Coding & Development · Next Topic »

Welcome Guest [Log In] [Register]
Outline Live
Loading..
Loading..