Forum Discussion
jgroves wrote:
I'd like some javascript to execute when a user clicks "post" when either begining a thread or replying.
This is very possible.
jgroves wrote:
Basically for many complicated reasons (too much detail to provide in this post)
Ahh the bane of the online forum.This is wildly off topic, but the reason this one gets in my way is that if I knew what problem you were trying to solve there might be a better way to do it. Like when the team who posts in our Blog spent weeks putting together a brief and then sent me a big pack on the feature they needed to develop for an essential tool. Until I pointed out we could just add a component for it.
But that's ok, let's solve the problem in front of us :)
The easiest way to do what you want is going to be to make your own custom components for the reply and post buttons.
Use CSS to hide the existing buttons and place yours there via studio.
Then write your javascript to check the post div on page load (why wait til it's clicked right :) ) and then either make the button generate an alert on click or function as normal.
You'll have to make sure you wrap the javascript in the Lithium wrapper so it queues up with the rest and executes after the page is ready.
I'd code it so it executes like this.
1. Page loads as normal, the post and reply buttons point to the reply page by default (this is your fallback for people without javascript enabled).
2. After the page is "ready" the code does a quick check of the right div and looks for the characters in question.
3. if it finds them it switches the innerHTML for the button to do an alert, or changes the button to disabled and shows a warning div.
4. if it doesn't find it, it does nothing.
This would cover you if the characters are found, if the characters are not found, and most of all if there is no javascript.
It's not perfect, it's a little clunky, and with javascript disabled people can still post.
It'll get the job done.
And leave me WILDLY curious what kind of content you're allowing to be posted but not replied to!
Use CSS to hide the existing buttons and place yours there via studio.
Then write your javascript to check the post div on page load (why wait til it's clicked right :) ) and then either make the button generate an alert on click or function as normal.
You'll have to make sure you wrap the javascript in the Lithium wrapper so it queues up with the rest and executes after the page is ready.
We have to keep in mind that by hidding the buttons, using CSS, the end user can always use the developer tools / FireBug on their web browser to make them visible again, and therefore post the character set they want ... ;-)
- Tim_h11 years agoBoss
OlivierS wrote:We have to keep in mind that by hidding the buttons, using CSS, the end user can always use the developer tools / FireBug on their web browser to make them visible again, and therefore post the character set they want ... ;-)
Sounds like I'm not the only one who constantly uses the developer console to touch things on webpages.
So many HTML comments to be found ;)
Related Content
- 11 years ago
- 10 years ago
- 14 years ago
- 12 years ago
- 11 years ago