Skip to main content

CSS, Javascript functionality issue relating to styled input buttons on newer browsers? (IE 8/9, FF 9)



I'm working on a site where I have input buttons (styled using CSS) that are a part of a form. For example, see below for sample code







<input type="submit" name="buttonSave" value="save" id="buttonsavejs" class="button_image button_style"/>







I've just found an issue where if a user clicks on the button, it moves a few pixels below and then expected action takes place intermittently . But intermittent , I mean that sometimes it works (redirects the user to the next page) and sometimes nothing happens.





The developer who worked on this previously hasn't documented his code much, so I'm trying to work from scratch here (so excuse the lack of details). Anyway, after testing the code, it appears that the issue lies with how newer browsers are rendering the css and javascript.





Here's a snippet of the javascript behind the button's functionality:







$("#buttonsavejs").click(function(){

$("#main").unbind("submit").submit();







And the CSS that styles the button







.button_style {

height:28px;

margin-left:10px;

position:relative;

right:10px;

top:-23px;

width:100px;

}



.button_image {

background-image:url(http://some_image);

border-bottom-width:0;

border-color:initial;

border-image:initial;

border-left-width:0;

border-right-width:0;

border-style:initial;

border-top-width:0;

display:block;

font-size:1px;

line-height:1px;

outline-color:initial;

outline-style:none;

outline-width:initial;

overflow-x:hidden;

overflow-y:hidden;

position:relative;

text-indent:-9999px;

}







Also, I noticed a very similar question asked here: Why do mouse clicks not always work for styled input buttons?





Another piece of what I've been able to find out so far. In IE 9's developer tools, if I switch the Document Mode to anything other than IE 8 or 9, the button behaves as it should. So one line of thinking I have is to set the X-UA-Compatible to IE 7 and see if that resolves it as, apparently, that's how the document mode in IE works: IE8 browser mode vs document mode





Question : After testing in FF (earlier versions < 9.0), IE 7, I noticed that the button works as it should. But in FF 9, Chrome 16, IE 8/9, it behaves as described above. Has anyone run into a similar problem and any advice on what I should be watching out for?


Comments

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.