PDA

View Full Version : two scripts in two diffrent pages but still not working!!



rahan
07-29-2006, 09:02 AM
hi i have two different scripts running on seperate pages,at first they were on the same page and didnt worked so i have seperated them but the proublem still exist.

one is from nvidia.com's driver download page which you choose product and related driver.the menu is quite simple to edit but when loading it uses


<body onLoad="InitializeMainCategory('document.welcome');">

the second one is a menu "slide menu" it uses this code to work on the page:


<SCRIPT language=javascript type=text/javascript>
<!--
var left=0
var topProductMenu=0

function getDeterminerPositionLoad() {
if (MTNAV_COMPAT) {
initMTNav();
toggleLoad();
}
}
onload=getDeterminerPositionLoad;

//-->
</SCRIPT>


how can i get them work together??the two both uses "onload" command and if i delete one the other work or viceversa.thank you for your help and sorry for my bad english i hope i could tell my proublem exactly..

BLiZZaRD
07-29-2006, 01:26 PM
I am not a JS guy in any way... but looking at the codes:

shouldn't the first one have the ; AFTER the " ?

so it looks like:



<body onLoad="InitializeMainCategory('document.welcome')";>


Okay, probably not.. but the second one, when you use the onLoad (not onload) you need the () in there also, like so:



onLoad=getDeterminerPositionLoad();


I might be wrong on both counts, but it seems logical to me... JS and Flash are pretty simialr and that's how you would use them in Flash, so I am going out on a limb here, LOL

rahan
07-29-2006, 01:49 PM
no it didnt solved the proublem,i have taken these codes from other sites and they are working quite well by themselves but when together one of them stops.

Twey
07-29-2006, 03:45 PM
shouldn't the first one have the ; AFTER the " ?No. Not in any way. :)

Okay, probably not.. but the second one, when you use the onLoad (not onload) you need the () in there also, like so:Also no. :)
JS and Flash are pretty simialr and that's how you would use them in FlashWrong. ActionScript is also a variant of ECMAScript, so the same rules apply.
If you have:
function myFunc() {
return true;
}Then:
var myVar = myFunc();myVar will be true. This is syntactically correct, but of a totally different meaning to:
var myVar = myFunc;... which will cause the entire function to be assigned to myVar, so that a future:
myVar();will return true.

rahan: He's completely wrong on this one, don't listen to him :) Instead, remove this line:
onload=getDeterminerPositionLoad;and edit the onload event like so:
<body onload="InitializeMainCategory('document.welcome');getDeterminerPositionLoad();">

BLiZZaRD
07-30-2006, 02:51 AM
No one should ever really listen to me :)

mburt
07-30-2006, 02:52 AM
In event handlers, putting a semicolon after or before the " won't do anything, it just seperates the previous function from another function, if necessary.

rahan
07-30-2006, 10:01 AM
Twey thank you so much for your answer they are working together al last!!but... :) but only on homepage it works.when i navigate to another page i get an error on the leftbottom of the explorer screen saying when i click on it:

line:342
char:3
error:'document.welcome.MainCategory', is either null or not an object
code:0

and the left scrolldown menu does not appear on the screen.here is the address of my site:

http://www.rmdbilgisayar.com

what is the proublem now

Twey
07-30-2006, 01:09 PM
I'm guessing you don't have an element called "welcome" on that page.

rahan
07-31-2006, 07:47 AM
yes its true document.welcome is only on the home page so i added this to main page's <head> tag:


<% if navpage<>1 then %>
<SCRIPT language=javascript type=text/javascript>
<!--
var left=0
var topProductMenu=0

function getDeterminerPositionLoad() {
if (MTNAV_COMPAT) {
initMTNav();
toggleLoad();
}
}
onload=getDeterminerPositionLoad;
//-->
</SCRIPT><%end if%>

and there is no proublem now.again thank you so much for your help friend i owe you one