Making Javascripts run on specific pages.
2 posters
Page 1 of 1
Making Javascripts run on specific pages.
I'll preface this question by saying that I am really bad at javascript, I very recently started trying to learn some basic stuff, so no judgment please.
As the title suggests I'm trying to a add a really basic script that will run on a specific thread of the forum. To do it, I went to javascript management and a created a script that would run on all pages. Then I put this as the content:
var window = window.location;
if (window === "http://www.superiorrp.org/t289-receive-vip") {
alert("test message")
}
Anyway, it completely failed, does anyone know how to fix this so it works, or know another method of making a script run only on a specific page of the forum. Thanks.
As the title suggests I'm trying to a add a really basic script that will run on a specific thread of the forum. To do it, I went to javascript management and a created a script that would run on all pages. Then I put this as the content:
var window = window.location;
if (window === "http://www.superiorrp.org/t289-receive-vip") {
alert("test message")
}
Anyway, it completely failed, does anyone know how to fix this so it works, or know another method of making a script run only on a specific page of the forum. Thanks.
Arrandale- New Member
- Posts : 4
Reputation : 1
Language : English
Re: Making Javascripts run on specific pages.
This would work for any topic :
Just keep adding else-ifs for more topics using the topic ids.
- Code:
(function(){
var r = /\/t(\d+)-.*/;
if(r.test(window.location.pathname)) {
var topic_id = r.replace(r,'$1');
if(topic_id == 289) {
alert('testing');
}
else if(topic_id == 1) {
}
}
})();
Just keep adding else-ifs for more topics using the topic ids.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Similar topics
» Making new member post 1st in a specific sub-forum
» Banner ads on specific pages
» CSS code for specific pages?
» Making the censorship specific to certain boards?
» Isolate Chatbox to specific pages?
» Banner ads on specific pages
» CSS code for specific pages?
» Making the censorship specific to certain boards?
» Isolate Chatbox to specific pages?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum