PDA

View Full Version : How to trigger 2 events on click?



JohnnyNight
07-14-2012, 02:51 PM
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

Philip M
07-14-2012, 04:43 PM
onclick = "function1(); function2()";

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

JohnnyNight
07-14-2012, 04:57 PM
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...

Philip M
07-14-2012, 06:47 PM
<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.

JohnnyNight
07-14-2012, 08:46 PM
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>

Philip M
07-15-2012, 09:43 AM
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. :)

JohnnyNight
07-16-2012, 01:43 PM
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.