| Simply put: Page-specific scripts | |
|---|---|
| Tweet Topic Started: Thursday, 7. July 2011, 14:06 (318 Views) | |
| Joe | Thursday, 7. July 2011, 14:06 Post #1 |
![]()
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 | Friday, 8. July 2011, 04:50 Post #2 |
![]()
Level 8
|
May I ask why do you put the '!== -1'? |
Visit my shop! Forum reviews, posting packages, recolors![]() ![]() ![]() Me! | |
Off
Profile |
Quote Top
|
| Aidan | Sunday, 7. August 2011, 14:30 Post #3 |
![]()
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 » |
| Track Topic · E-mail Topic |
8:15 PM Jul 10
|
Powered by ZetaBoards Premium · Privacy Policy



Multi
Multi





Thank you Brendan for the image! 

8:15 PM Jul 10


Outline Live