48 users online (0 members and 48 guests)  


  Results 1 to 8 of 8

Related

  1. what is the alternative today to AD sense?    Forum: Affiliate Marketing and Reseller Programs
    Replies: 10
  2. an alternative to link exchange    Forum: General Discussion
    Replies: 0
  1. #1
    benzden's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2002
    Location
    San Antonio, Texas
    Posts
    652

    Alternative to .caller or ??? for .js sub-routines?

    Is there an alternative to the NN 6 deprecated .caller or ?another? method of calling a function within a .js file that will gather a value and either return it or pass it along to another function?


    In other words, something like the BASIC SUB function - don't know what it is in C or C++ if they have it.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    You can call a function within a function in JavaScript (modelled after Javas' 'inner methods') but they are generally more hassle than they are worth.

    Thing to watch with them is that the variables are accessible to both the outer and inner functions, probably best to make them global.

    Is this what you mean? if I am on the right track, I'll post some examples.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    benzden's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2002
    Location
    San Antonio, Texas
    Posts
    652
    Yes, I figured the process would involve threading through various <SCRIPT ...>s, accumulating variables and passing them along to the final <SCRIPT ...> and, yes, a simple example would help. (Mine will be included within a master .js file that includes all the functions being accessed.)

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Here you go. It also demonstrates local, global and passed variables.

    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
    function innerFunction(alertMe) {
    alert(alertMe);
    alert(notPassed);
    }
    function outerFunction() {
    var doNothing='I cannot be passed, I am local';
    var passingVariable='I am a passed variable so local works';
    notPassed='I am not passed but I am global';
    innerFunction(passingVariable);
    alert('Now I am finished');
    }
    //-->
    </script>
    <a href="javascript:outerFunction();">click</a>
    Its worth trying to alert(doNothing); in the innerFunction to see the error you get (down to the fact that its a local variable and it was not passed to the innerFunction).

    Edit: To disable smilies. A surprised face in code never works, it just makes people worry about you :)
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    benzden's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2002
    Location
    San Antonio, Texas
    Posts
    652
    Thanks, again, as usual - you da man, QD!

    The process has been incorporated into http://Test.Gumint.com toward the bottom of the page as passing variables (function to function).

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Nice! I like the explanatory error. I shoulda thought of it, but I'm lazy
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  7. #7
    benzden's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2002
    Location
    San Antonio, Texas
    Posts
    652
    Lazy?! Hah! You're the 2nd hardest working person in these forums - we all know who's at top of that heap (and it ain't me.)

  8. #8
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    Do tell...I always thought it was Dean

    D
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting



Tags for this Thread