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

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex