Forum Moderators: open
But this fails for the non-javascript browsers for obvious reasons. A neat thing you can do is the following:
<a href="something.html" onClick="popupPage('something.html');return false;" target="_blank">text</a>
The return false in the javascript tells the browser to stop performing other actions associated w/ that event, such as opening something.html a second time. But if js is turned off, there will be no return false and something.html will still be loaded in a new window.
This is also great for links where you want a j/s popup box that says something like "Are you sure, yes/no". Just return true/false back to the onClick parameter and without j/s, it defaults to 'yes'. This also works for onClick's for submit buttons in forms. I hate all those submit buttons where you can only submit if j/s is enabled b/c of client side validation code.
Anyway, I just ran into this. Perhaps it isn't news to many of you, I dont know.
But for form submissions, I wouldn't pop up an "are you sure?" dialogue. It's far more effective to return a copy of the filled-in form and provide buttons to "Submit" and "Edit". Users are more likely to spot errors that way.
Arrange for the form validation script to return true for a correctly filled-in form, and false if it contains errors. Then include the following event handler in the <form> tag:
onsubmit="return check(this);"
Without JavaScript, the form will be submitted, but possibly with errors -- it goes without saying that you need a client-side validation script as well.
<edit>
Well, on re-readingyour original post, I guess you didn't mean quite what I thought you said about form submissions -- but I still stand by what I said. :)
</edit>
Does that ring any bells?
Tom