Forum Moderators: open

Message Too Old, No Replies

yet another multi js conflict question

         

maques

10:31 pm on Mar 11, 2004 (gmt 0)

10+ Year Member



hey everyone... i realize this has been covered before but i can't seem to find the answer. i have overlib js which works fine by itself. and i have opencube js which works fine by itself. put them together and only 1 will work depending on which is listed first under <body>. any suggestions how to find the conflict? help! thanks.

Purple Martin

12:35 am on Mar 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check for duplicated function names - you can't have the same name in both files. This is because the browser reads all the .js files into the HTML file, so it all becomes one big file in the browser's memory.

maques

1:20 am on Mar 12, 2004 (gmt 0)

10+ Year Member



these two are pretty good in that respect - they seem to stick to prefacing each function with ol_ and dqm_ respectively... is this:

document.onmousemove=

a function? because this is the only thing i found that appears in both. i need help!

thanks.

Purple Martin

2:14 am on Mar 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



document.onmousemove= defines the event handler for mouse moves over the document. If you define it twice, only the second one will be used (just like if you set the value of a variable, then set it to something else). So if both files rely on this, I would expect only the second one to work (however you said only the first one works).

Another thing to look out for: make sure you don't have any unclosed functions or 'if' statements or 'for' loops or strings (particularly near the end of a file, as the problem seems to be stopping the second file from working).

Do you get a yellow exclamation icon in the bottom left of the browser window? (IE). If you do, double-click it and look at the error message for clues.

maques

2:31 am on Mar 12, 2004 (gmt 0)

10+ Year Member



actually, you're absolutely correct - it IS the second one that works (i think i may've worded my initial post awkwardly)... and it appears that document.onmousemove IS the culprit... it shows up as document.onmousemove=q80 in one, and as document.onmousemove = mouseMove in the other. is there any way to rename or somehow circumvent this or am i screwed? again, thanks for your help.

Purple Martin

2:58 am on Mar 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could make your own function to do both.

doBoth() {
eval(q80)
eval(mouseMove)
}
document.onmousemove="doBoth()"

I think this might work - from what you posted it appears that q80 and mouseMove are variables that hold code to execute - I think - which is why I used eval(). Anyway, even if I'm wrong about what q80 and mouseMove do, the idea of calling a function that does two things is still OK.

maques

1:50 pm on Mar 12, 2004 (gmt 0)

10+ Year Member



thank you. that sounds perfect in principle but i'm afraid a little over my head. i have no idea how to implement that code. looks like i'll need to search for alternate solutions. thanks for your help!

- max