www.webdeveloper.com
Results 1 to 7 of 7

Thread: NooB Question: Give multiple functions for a button?

  1. #1
    Join Date
    Sep 2009
    Posts
    5

    NooB Question: Give multiple functions for a button?

    Hello everyone,

    I am new to all of this. I have just started my own website and I'm learning little by little. What I want to do (if it is possible) is to have a page and on that page a button that says "ENTER" or anything like that and when that button is clicked, I want two things to happen:

    1) That page will be redirected to a specific URL.
    2) Open a pop-up BEHIND the main window (a pop-under if you will).

    Now, I have looked around and found a site that helps make a button with the function to open a pop-under when the user clicks a button.

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    
    function goNewWin() {
    
    //***Get what is below onto one line***
    
    TheNewWin =window.open("popunderexample.html",'TheNewpop','toolbar=1,
    location=1,directories=1,status=1,menubar=1,
    scrollbars=1,resizable=1');
    
    //***Get what is above onto one line***
    
    TheNewWin.blur();
    
    }
    </SCRIPT>
    
    <CENTER>
    <FORM>
    <input type="button" VALUE="click me!" onClick="goNewWin()">
    </FORM>
    </CENTER>
    That is what I'm trying to do. Is this possible? If so, what code should I use and where in my HTML do I put it (HEAD, BODY, etc.)?

    Thanks in advance.

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by ns4u View Post
    2) Open a pop-up BEHIND the main window (a pop-under if you will).
    Modern browsers have TABS and their default setting is to open a pop-up in a new tab, not in a new window, thus there is no "pop-under" possible position. And people usually hate pop-ups, not a bright idea to use them anymore.

  3. #3
    Join Date
    Sep 2009
    Posts
    5
    Yes but that does not answer my question...

    If you try that code I posted in m original post, you will see it opens a pop-up behind the main window so it does not bother anyone until they leave the site. I tried it with Firefox and it did exactly that.

    If anyone could help me answer my original questions please:

    1) That page will be redirected to a specific URL.
    2) Open a pop-up BEHIND the main window (a pop-under if you will).

    Thanks.

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by ns4u View Post
    Yes but that does not answer my question...
    Really? Oh, but it does answer your question, and the answer is: you can not place a pop-up behind the window, except for old browsers which is not enough. Shall I repeat that? If it worked with your Firefox, that is probably because you have changed its settings and make it open the pop-ups as new windows.

    Ok, forget it, I'll have a closer look and I'll try to give you an answer the way you want it.
    Last edited by Kor; 09-02-2009 at 10:11 AM.

  5. #5
    Join Date
    Sep 2009
    Posts
    5
    Ok I see... You did answer... But what I am most concerned about is putting multiple functions when someone clicks a button. How do I this?

  6. #6
    Join Date
    Sep 2009
    Posts
    5
    @Kor

    First off excuse me for being rude in my first reply. Secondly, I was curious about what you said so I tried this code in 2 browsers and it was a success:

    1) Firefox 2.0.0.20
    2) Internt Explorer 7.0.5730.13

    I guess what I am only interested in now, seeing these results, is to add another function to that same button in additon to the pop-under. I would like the page with the button to then redirect to another url.

    Thanks for all your help and quick responses and I again I apologize.

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Ok. Let's start with your basic question: Give multiple functions for a button

    That is simple:
    Code:
    <input type="button" value="click me!" onclick="functionOne();functionTwo();functionThree()">
    Simply write the functions you need to be fired separated by semi colons.
    Last edited by Kor; 09-02-2009 at 02:19 PM.

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