The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Simple question: How to add custom JavaScript to forum

View previous topic View next topic Go down

Solved Simple question: How to add custom JavaScript to forum

Post by iamataloss on December 5th 2011, 7:11 am

Hello. I'm wondering how to add custom JavaScript code to my forum? I'm using phpBB2.

Thanks!


Last edited by iamataloss on December 7th 2011, 6:41 am; edited 1 time in total

iamataloss
New Member

Posts : 17
Reputation : 1
Language : English

Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by c3vietk on December 5th 2011, 7:25 am

ACP ~> Modules ~> Javascript codes management

c3vietk
Forumember

Male Posts : 65
Reputation : 41
Language : Vietnamese, HTML, Javascript, C#, PHP
Location : Vietnam, HCMc

http://diendan.chinhphuc.info/

Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by Guest on December 5th 2011, 2:17 pm

Please read this topic if your forum version is phpBB2. Wink

Below "The applications of this innovation are endless and can completely transform your forum. They are limited only by your imagination and your JavaScript skills " you have to read something important! Wink

Guest
Guest


Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by iamataloss on December 6th 2011, 4:47 am

Is it different for jQuery?
As a test, I went to the Javascript codes management page and added the following code:

Code:
$('body').css("display","none");
It didn't effect the page at all. Is there anything I'm doing incorrectly?

iamataloss
New Member

Posts : 17
Reputation : 1
Language : English

Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by robot_boy18 on December 6th 2011, 5:57 am

Hello, you can add css at Color >> Css. Jquery
If you want to use jquery, it should look like this one Wink
Code:
$(function(){
$("body").css("display","none");});

robot_boy18
Forumember

Male Posts : 107
Reputation : 7
Language : English
Location : Greenville, South Carolina, USA

http://en.fmvi.org/

Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by kirk on December 6th 2011, 10:17 am

why dont you add your css to your css page?
It sounds like you may be making things more difficult then they have to be?

But we would need to know exactly what it is your trying to do and see the scripting your trying to use to better help you in the right direction.

Or explain as much as you can.

kirk
Forumaster

Male Posts : 11037
Reputation : 651
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by Guest on December 6th 2011, 4:13 pm

Very strange about your code, lol. To give the body selector display: none it's like to hide your forum content, all forum. May you explain more?

Guest
Guest


Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by LGforum on December 6th 2011, 4:29 pm

As they explained that code was just as a test.

The reason it didn't work is because the script go in to the header of the page. That script would have been executed before the body tag had even loaded. For such scripts which require the DOM to be loaded, you need to contain it within the a jQuery DOM ready function, which means the script will wait until the DOM is fully loaded before executing.

As someone mentioned above that would be this:

Code:

$(function(){

code here

});

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by iamataloss on December 7th 2011, 6:41 am

@LGforum wrote:As they explained that code was just as a test.
Exactly, I was trying to think of something that would be a very noticeable test and that was the first thing that came to mind.

@LGforum wrote:The reason it didn't work is because the script go in to the header of the page. That script would have been executed before the body tag had even loaded. For such scripts which require the DOM to be loaded, you need to contain it within the a jQuery DOM ready function, which means the script will wait until the DOM is fully loaded before executing.

As someone mentioned above that would be this:

Code:

$(function(){

code here

});
I thought for sure I had tried that already, I was wrong. Works perfectly, thanks everyone!

iamataloss
New Member

Posts : 17
Reputation : 1
Language : English

Back to top Go down

Solved Re: Simple question: How to add custom JavaScript to forum

Post by Nera. on December 7th 2011, 8:20 am

Topic Solved & Locked

Nera.
Energetic

Female Posts : 7077
Reputation : 2013
Language : English
Location : -

http://webartzforum.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum