Results 1 to 9 of 9

Thread: two scripts in two diffrent pages but still not working!!

  1. #1
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default two scripts in two diffrent pages but still not working!!

    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

    Code:
    <body onLoad="InitializeMainCategory('document.welcome');">
    the second one is a menu "slide menu" it uses this code to work on the page:

    Code:
    <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..

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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:

    Code:
    <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:

    Code:
    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
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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 Flash
    Wrong. ActionScript is also a variant of ECMAScript, so the same rules apply.
    If you have:
    Code:
    function myFunc() {
      return true;
    }
    Then:
    Code:
    var myVar = myFunc();
    myVar will be true. This is syntactically correct, but of a totally different meaning to:
    Code:
    var myVar = myFunc;
    ... which will cause the entire function to be assigned to myVar, so that a future:
    Code:
    myVar();
    will return true.

    rahan: He's completely wrong on this one, don't listen to him Instead, remove this line:
    Code:
    onload=getDeterminerPositionLoad;
    and edit the onload event like so:
    Code:
    <body onload="InitializeMainCategory('document.welcome');getDeterminerPositionLoad();">
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    No one should ever really listen to me
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    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.
    - Mike

  7. #7
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry

    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

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I'm guessing you don't have an element called "welcome" on that page.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Jul 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yes its true document.welcome is only on the home page so i added this to main page's <head> tag:

    Code:
    <% 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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •