www.webdeveloper.com
Results 1 to 3 of 3

Thread: How to merge, combine two different functions in javascript?

  1. #1
    Join Date
    Aug 2013
    Posts
    2

    How to merge, combine two different functions in javascript?

    Hello, world! I need help on something.I don't know much about javascript and I have two different scripts to merge, combine or whatever they call it:

    function doSomething() {}

    (function loop() {
    var rand = Math.round(Math.random() * (30000 - 1000)) + 1000;
    setTimeout(function() {
    alert('A');
    doSomething();
    loop();
    }, rand);
    }());

    And this one:

    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen…
    if(pos=="center"){LeftPosition=(screen…
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20…
    settings='width='+w+',height='+h+',top…
    win=window.open(mypage,myname,settings…

    Can someone help me on this matter?

    My thanks to everyone.

  2. #2
    Join Date
    Mar 2009
    Posts
    430
    Maybe I don't understand your question.
    If you have two functions, A and B, you can handle it several ways:

    Code:
    //write a new function that calls them both in whatever order you want
    function C(){
      A();
      B();
    }
    
    //modify one to call the other
    
    function A(){
      //the stuff that's already there
      B();
    }

  3. #3
    Join Date
    Aug 2013
    Posts
    2
    Quote Originally Posted by Tcobb View Post
    Maybe I don't understand your question.
    If you have two functions, A and B, you can handle it several ways:

    Code:
    //write a new function that calls them both in whatever order you want
    function C(){
      A();
      B();
    }
    
    //modify one to call the other
    
    function A(){
      //the stuff that's already there
      B();
    }
    Hey,thanks for the reply.Good thinking.How can I apply this idea on the two functions?Just replacing the letters?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles