Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to trigger 2 events on click?

    Hi All,

    Awesome Site, first post...

    Trying to figure out how to trigger 2 events when clicking - CONTINUE - button on index page.

    I have code that is generated by NetObjects Fusion 9. I edit it in Notebook.

    1st event - launch new window with target blank (this is working)

    2nd event - redirect index page to another page in site after click. (not working)

    I've tried a few different things, just can't seem to get it going. Been out of the web site biz for a few years and forgot alot of things, and figuring out doesn't seem as easy as it use to be

    This is the code of I have:

    <td colspan="5" width="693" class="TextObject" style="background-color: rgb(255,255,0);">
    <p><span style="font-family: Impact, 'Arial Black', 'Helvetica Bold', Charcoal, Sans-serif; font-size: 60pt; color: rgb(0,153,255);">&nbsp;&nbsp;<A STYLE="text-decoration:none" href="http://urlgoeshere.com/html/4.html" target="_blank"><span style="color: rgb(0,153,255);">CONTINUE</a></span></p>
    </td>

    tried incorpating the below code in the above to get it to work, but no success yet.

    function myFunction() {
    launchWindow();
    window.location = 'http://www.example.com/';
    }

    -------------------

    Any ideas greatly appericated...

    Thanks

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    onclick = "function1(); function2()";

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Philip,

    Thank you very much for this script...

    To be honest, while I'm sure you understand how to incorporate it into what I have, let me see if I know how to do this.

    So would it be...

    <td colspan="5" width="693" class="TextObject" style="background-color: rgb(255,255,0);">
    <p><span style="font-family: Impact, 'Arial Black', 'Helvetica Bold', Charcoal, Sans-serif; font-size: 60pt; color: rgb(0,153,255);">&nbsp;&nbsp;<A STYLE="text-decoration:none" onclick = "function1<href="http://urlgoeshere.com/html/4.html" target="_blank">function2< ..html/4.html>";
    span style="color: rgb(0,153,255);">CONTINUE</a></span></p>
    </td>

    Incorpating the code, for me right now is just as tricky as figuring out what it should be...
    Last edited by JohnnyNight; 07-14-2012 at 04:58 PM. Reason: revise code

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Code:
    <a href = "javascript:void(0)"; onclick = "do2things()" >CONTINUE</a>
    
    <script type = "text/javascript">
    function do2things() {
    launchWindow();
    window.location = 'http://www.google.com/';
    }
    
    function launchWindow() {
    alert ("This function has been called");
    }
    
    
    </script>

    Note that javascript:void(0) is required to prevent the page from reloading when the link is clicked.

    But an anchor tag is not semantically the right way to do this. You should use a button. You can easily style button elements to look like normal links.
    Last edited by Philip M; 07-14-2012 at 06:53 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you Philip...

    So if I have 2 destinations in the code it would look like this...

    -----------------------

    <a href = "javascript:void(0)"; onclick = "do2things()" >CONTINUE</a>

    <script type = "text/javascript">
    function do2things() {
    launchWindow();
    window.location = 'http://www.google.com/';
    }

    function launchWindow() {
    alert ..html/4.html';
    }


    </script>

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Sorry, I do not really understand what you are trying to do. You cannot have two "destinations" (urls) triggered by the same event. You cannot launch a window and then redirect to another site as the window is immediately replaced.

    All I can suggest is that you revise your knowledge of HTML and Javascript.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Philip,

    Yeah, I guess my message was a little unclear.

    The first destination was the target blank window launched on the click from the index page.

    The second destination was the index page itself redirecting after the click.


  •  

    Posting Permissions

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