Jump to content

Small Issue


jaymc

Recommended Posts

I have the following code...

[code]OnClick="return confirmblock(); window.location='http://google.co.uk';"[/code]

The problem is, regardless of the [b]confirmblock();[/b] outcome which is [b]ok/cancel[/b] window.location still goes ahead and executes

Now I have a fealing the space between [b]return confirmblock[/b] is confusing the javascript and for some reason then ignoring the window.location request in the 2nd part of the OnClick event

Any ideas...

Thanks
Link to comment
https://forums.phpfreaks.com/topic/26269-small-issue/
Share on other sites

This is what I tested and it worked:
[code]<span onclick="var doYou = confirm('Do you really want to go?'); if (doYou) self.location.href = 'http://google.co.uk';">Test</span>[/code]
I take it that's basically what you're trying to do.  This is just a guess but it almost seems to me like where script is getting confused is in what to do with the true/false; return it as a variable, or return it on the event.
Link to comment
https://forums.phpfreaks.com/topic/26269-small-issue/#findComment-120141
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.