![]() |
return false; not working...
Hi all,
I have a page built with asp.net that includes some "imagebutton"s within a form. These render as input tags with the type set to image. I ahve the onclick attribute set to run a custom javascript function and return false, so in the fully rendered page I get something like the following: Code:
<input type="image" name="ctl00${cut}" tabindex="-1" title="Click to look up the details" src="images/load_details.png" onclick="LoadDetails(); return false;" style="border-width:0px;" />The browser being used throughout the company is IE8 under Windows XP. I have checked the version being used on their comptuer and it is 8.0.6001.18702, which is the same version as the one installed on my local machine... which is working fine. Another user has logged into the computer being used by the user with the issues and it works fine for the second user. Also, the user having the issues has logged into a different computer on the network and was still having the same problems. I think I've included all the details, but I'll happily provide any required information. Anyone have any ideas? :) |
Have you already confirmed this user has Javascript enabled? You can either look through the IE settings or push a noscript tag into the page.
|
Quote:
|
return false will stop the execution of the event which calls it. As long as you call it onclick, the event stopped will be onclick, not onsubmit. The submit action belongs to other element: the FORM element, thus I think your code should look like:
Code:
<form action="" onsubmit="return LoadDetails()"> |
Quote:
- there are multiple javascript based buttons on the same page. - certain javascript based links/image buttons in the page work fine. - I added the url (http://intranet_address) to trusted sites and changed the trusted site security level to "low" The links that seem to work fine are the ones that require the page to be submitted, e.g. there's a "cancel" link that simply takes the user back to the main listing (the page with the issues is used for data editing). This renders as: Code:
<a id="{id}" href="javascript:__doPostBack('{id}','')">Cancel</a>This is why I titled the post "return false; not working" - because javascript is working fine, it's just the "return false;" part that doesn't seem to do anything... |
Quote:
Quote:
The image button is suposed to be using AJAX to load details from a remote server. Another image button in the same form is supposed to make the name entered into a textbox "Proper Case". (and there's a number of other buttons used to process things client side) The whole form is being used to add/edit a record in the database... obviously, moving the javascript to the onsubmit event wouldn't work in this case. |
Quote:
Once again, the submit action can be stopped only within the FORM element while using return false the the onsubmit event. Code:
<form action="" onsubmit="return false"> |
Quote:
|
Quote:
What is not clear? Do you have other submit/image inputs within the same form? |
Quote:
Does that mean that you're telling me that the other 99.9% of computers making use of the page, where clicking this button doesn't submit the form because I have "return false;" in the onclick event are behaving incorrectly? That the correct behaviour would in fact be to allow the form to submit instead? Quote:
Quote:
Further to the information provided so far, this only seems to happen under the single user's profile. Someone else logging into the same computer was able to use the pages correctly and the user logging into a different computer didn't help - the image button still submitted the page. |
Quote:
|
| All times are GMT +1. The time now is 12:54 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.