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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.