Results 1 to 10 of 10

Thread: Styling and coding the select box: crossbrowser treatment

  1. #1
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,875
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default Styling and coding the select box: crossbrowser treatment

    1) CODE TITLE: Styling and coding the select box: a crossbrowser treatment

    2) AUTHOR NAME/NOTES: Arie Molendijk

    3) DESCRIPTION: A crossbrowser treatment of styling and coding the select box. This does not focus on css-beauty, but on crossbrowser functionality. Some features: how can we force IE to behave like non-IE as regards to the width of the select box; how can we do function calls in the options in both non-IE and IE?

    4) URL TO CODE: http://www.let.rug.nl/molendyk/selec...selectbox.html
    Last edited by molendijk; 01-24-2010 at 12:36 AM. Reason: Correction

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This does not focus on css-beauty
    And as far as I know, it will probably be many years before any cross browser solution to any form element can. Unless of course it focuses on the use of images and surrounding divisions and/or a virtual or totally complete replacement of the element with other markup via the DOM or other methods.

    As usual, I'm betting that your response will entice me to look at your actual code, which I haven't yet.

    In the meantime, have a look at this odd bit of code (only enhanced by me, I'm not sure who originated it, though I've documented as usual all known sources if any in the code) for the text input:

    http://home.comcast.net/~jscheuer1/side/pretty_input/

    Only the top and bottom text inputs receive the treatment, and each in slightly different ways. Play with them if you will.
    Last edited by jscheuer1; 01-24-2010 at 01:58 AM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,875
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Actually, this thread is more about what you cannot do, as far as styling of select boxes is concerned, than about what you can do.
    My main concern was to have (some primitive but decent layout plus) a way to call functions in the options.
    Also, what always has irritated me is that there is no proper way in IE to size the options indepentendly from the box. So I wrote some lines of code serving as a workaround. I borrowed one or two lines from a site I cannot find any more.
    Thanks for the link. I'll try to apply the code to my boxes. Have to study it first.
    ===
    Arie.
    Last edited by molendijk; 01-24-2010 at 01:10 PM. Reason: Correction

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Looks pretty cool actually. Two minor things, probably both easily fixed. In Chrome and Safari both the foreground and background color of the options are white until hovered. In IE 7 your pop up window (Google in new window) is blocked.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,875
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Thanks! I'll fix the Chrome/Safari-thing. As for the blocked popup, that is not typical for select boxes, I think.
    ===
    Arie.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Blocking a pop up generally occurs when the browser 'thinks' that the javascript request for it wasn't made by the user. Usually if the javascript request happens as a direct result of user action, it's fine. It does work in Firefox, in Chrome it opened a new tab, which is almost as good. If there is a timeout or interval introduced, this will usually cause any browser to block it. However, merely relying upon an onchange event may be all it takes for IE. The 'gold standard' for this is the onclick event. If you can get the browser to think it was as a result of a click by the user, it will almost always allow it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,875
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Quote Originally Posted by jscheuer1 View Post
    If you can get the browser to think it was as a result of a click by the user, it will almost always allow it.
    Yes, you're quite right. Now, in my case, I have if (optionValue=="popup") {window.open(some url)} in a function coding_box(which_box) which is fired with an onchange event. This may be seen by the browser as too 'indirect', the result being a 'non-allowance' for security reasons (?).
    ===
    Arie.

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes. If you set up a click attachEvent() - the IE way of event listening for the element, you may be able to get it to work. The attachEvent() method is a bit arcane as compared to the addEventListener() method of other browsers, so that fact added to the fact that you are also firing the onchange event may make it tricky. But if you want your select to be able to do this type of thing in IE, definitely worth the effort. You aslo may use the element's onclick event directly (attribute onclick) or via a javascript assignment (el.onclick=function(){}). If you've replaced portions of the select with another element(s) for display purposes in IE, it is these new elements that the onclick should fire from.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. The Following User Says Thank You to jscheuer1 For This Useful Post:

    molendijk (01-24-2010)

  10. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You could try something like:
    onClick="if (not) { ...... return false; } popup();"
    Wouldn't that feel direct?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  11. The Following User Says Thank You to djr33 For This Useful Post:

    molendijk (01-24-2010)

  12. #10
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,875
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    John and Daniel, thanks for your suggestions. I'll try them as soon as I've got some more time.
    In the meantime, I fixed the Chrome/Safari-problem (explained in the (revised) demo).
    ===
    Arie.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •