| Author |
Message |
wiz Client

Joined: Oct 09, 2006 Posts: 355 Location: UK
|
Posted:
Thu Dec 21, 2006 6:47 pm |
|
Ok heres the question, written by a noob..hopefully generating answers for many noobs.
A lot of blocks use javascript to perform 'animations' or 'scrolls'
So you add your shoutbox for example. Then your clock stops working. So you turn it off, then your clock works fine, but then you add snow for a christmas feel, and your shoutbox stops working.
I saw on Nukecops someone (possibbly Evaders99) post that you could incorporate the .js scripts into your javascript.php
But how? and where?
personally i tried saving the .js for the blocks as seperate files and putting them in the /includes folder, then using an include "includes/shoutbox.js" blah blah at the relevant line in the mainfile script.
Doesnt work
So how do we do it? |
|
|
|
 |
persona_non_grata

Joined: Posts: 0
|
Posted:
Thu Dec 21, 2006 7:32 pm |
|
have a look in
includes/javascript.php |
|
|
|
 |
Gremmie Former Moderator in Good Standing

Joined: Apr 06, 2006 Posts: 2401 Location: Iowa, USA
|
Posted:
Thu Dec 21, 2006 9:14 pm |
|
You can write <sc~ript> tags that reference distinct javascript files. Where you might be running into trouble is if the javascript files conflict with each other. Maybe one of your blocks generates an HTML element with a certain ID, and you have identical or similar javascript trying to manipulate that same ID. |
|
|
|
 |
wiz Client

Joined: Oct 09, 2006 Posts: 355 Location: UK
|
Posted:
Thu Dec 21, 2006 11:59 pm |
|
yeh thats what foxxed me, i took a look at it but obviously thats written in php and we need javascript. so effectively u are asking one language to use another. |
|
|
|
 |
Gremmie Former Moderator in Good Standing

Joined: Apr 06, 2006 Posts: 2401 Location: Iowa, USA
|
Posted:
Fri Dec 22, 2006 12:38 pm |
|
Well, not sure what you mean. In some Javascript files I've seen, they hardcode HTML elements. You can simply change that and the PHP code so they don't conflict with other scripts on the same page. You can also make PHP code generate Javascript and ensure uniqueness that way. So one language can use another. |
|
|
|
 |
djmaze Subject Matter Expert

Joined: May 15, 2004 Posts: 557 Location: http://tinyurl.com/5z8dmv
|
Posted:
Fri Dec 22, 2006 3:16 pm |
|
get rid of all those very outdated document.onload and window.onload freaks.
Fix the d*** scripts to addEventListener() and attachEvent() then they all work on the same page. |
|
|
|
 |
wiz Client

Joined: Oct 09, 2006 Posts: 355 Location: UK
|
Posted:
Fri Dec 22, 2006 6:05 pm |
|
| djmaze wrote: | get rid of all those very outdated document.onload and window.onload freaks.
Fix the d*** scripts to addEventListener() and attachEvent() then they all work on the same page. |
Interesting..but remember the keyword in the original post.
I am that noob |
|
|
|
 |
djmaze Subject Matter Expert

Joined: May 15, 2004 Posts: 557 Location: http://tinyurl.com/5z8dmv
|
Posted:
Fri Dec 22, 2006 7:41 pm |
|
find inside your scripts
| Code: | | *.onload=functionname |
replace with
| Code: | /* xbrowser add event listener */
if (window.addEventListener) {
window.addEventListener('load', functionname, false);
} else if (window.attachEvent) {
window.attachEvent('onload', functionname);
} else {
// alert("Could not attach event to element.");
} |
that's it |
|
|
|
 |
wiz Client

Joined: Oct 09, 2006 Posts: 355 Location: UK
|
Posted:
Sat Dec 23, 2006 9:40 am |
|
that works a treat!!!
cheers guys
 |
|
|
|
 |
wiz Client

Joined: Oct 09, 2006 Posts: 355 Location: UK
|
Posted:
Sat Dec 23, 2006 9:42 am |
|
or it did!!!
worked for about 5 mins then suddenly stopped |
|
|
|
 |
|
|
|
|