views:

139

answers:

2

Hello,

I am currently working on a Javascript program for my company (Leader Technologies) that is used to register products for Logitech. The URL for that is : http://wwwtest.onlineregister.com/logitechreg/

My program looks totally fine on everything single web browser (including IE 6) that I have tried except Safari 4. On Safari 4, after a location, language and product category have been selected, when the actual product menu is clicked (id=WHPR), the div responsible for displaying the product is shown, but the drop-down selections are still visible. On all other browsers, the drop-down and the possible selections inside it in hidden (which is the intended behavior.)

Directly, my question is can I hid this drop-down successfully in Safari 4 WITHOUT completely emptying out the drop down and then repopulating it with only the selected value? I would rather not do this if at all possible, but if it's the only way to accomplish my goal then I can change the site additionally.

I believe the problem is where I set the listeners on the <select> :

<select id="WHPR" class="ui-formulate-ignore" style="width: 280px; visibility: visible;" onchange="whprChanged(this);" onfocus="displaySelector(form, document.getElementById('WHPR')); document.getElementById('imageHolder').focus(); this.blur();" name="WHPR">

Thank you all very much for taking the time to help me. I really appreciate all the help available on this site.

-Brian J. Stinar-

+1  A: 

I think it's some kind of a bug in Safari - for example if you do .focus() nof for the DIV but for another input element like a textfield, then after clicking the selectbox both would have the focus (or actually, the focus would stay in the selectbox and the textbox would only seem to have the focus by having thicker border than usual).

Anyhow quick and dirty methot to achieve the goal would be removing the selectbox from the page (display: none) and then bringing it back (display:inline).

replace the this.blur() with the following command

this.style.cssText='display:none';var select = this; window.setTimeout(function(){select.style.cssText='display:inline';},1);

If you don't use a delay then it doesn't work - the removal and retrieval of the element need to be in different scopes.

Andris
Thank you very much for your suggestion. This was very quick and easy to implement, and solved my problem. An issue I had to address with this was to put all of the css that should affect the element I am interested in (width: 280px; display:inline) in the cssText="..." area. I would like to use the above jQuery suggestion, but as I am under time pressure and your solution worked perfectly, so this is what I ended up using. I also had to slightly modify it due to an IE 6 z-ordering problem. If I bring the drop-down back after a second, IE6 places it on top of my selector div. Thank you.
Brian Stinar
Actually you don't have to put all the styling into the cssText propery. All CSS declarations in their nature against earlier declarations are appending not replacing - hence the term CASCADING in Cascading Style Sheets.So if you have somewhere declared that an input should be 280px wide then you don't have to declare it again.
Andris
Odd, the width was getting wiped away.
Brian Stinar
+4  A: 

Not to pick on your style, but attaching listeners inline like you're doing is not very clean. Why not take advantage of jQuery's ability to deal with any browser discrepancies? The page you refer to is already loading it.

See http://docs.jquery.com/Events/bind

Claude
Thank you for the suggestion. I did not take advantage of jQuery's ability to deal with any browser discrepancies because I was completely unaware of the fact that jQuery supported that feature. This was my first serious Javascript program. I am still becoming familiar with web development, and have only created this and a user input validator in Javascript so far. However, the next time I have an issue with a browser discrepancy (which, as I become more involved in web development, will be very soon) I will look into this for sure. Thank you very much for your suggestion and advice.
Brian Stinar