The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Simple question: How to add custom JavaScript to forum

+2
c3vietk
iamataloss
6 posters

Go down

Solved Simple question: How to add custom JavaScript to forum

Post by iamataloss 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
avatar
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 December 5th 2011, 7:25 am

ACP ~> Modules ~> Javascript codes management
c3vietk
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 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
avatar
Guest
Guest


Back to top Go down

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

Post by iamataloss 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?
avatar
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 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");});
avatar
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 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
kirk
Forumaster

Male Posts : 11037
Reputation : 653
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 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?
avatar
Guest
Guest


Back to top Go down

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

Post by LGforum 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
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

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

Post by iamataloss 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!
avatar
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. December 7th 2011, 8:20 am

Topic Solved & Locked
Nera.
Nera.
Energetic

Female Posts : 7078
Reputation : 2017
Language : English
Location : -

Back to top Go down

Back to top

- Similar topics

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