Results 1 to 3 of 3

Thread: Feature Detection: CSS3 Resize Property

  1. #1
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Smile Feature Detection: CSS3 Resize Property

    Hi all,

    Is there a way to test if the client supports the resize property?

    EDIT: Figured it out, thanks to Filament Group and MDC.

    Code:
    	try{ // CSS3 Resize Test
    		document.styleSheets[0].insertRule("#css3-resize-test { display: none; resize: both; }", document.styleSheets[0].cssRules.length);
    		var oResizeTest = document.createElement("textarea");
    		oResizeTest.id = "css3-resize-test";
    		document.body.appendChild(oResizeTest);
    		if(window.getComputedStyle(oResizeTest, null).getPropertyValue("resize") == "both"){
    			// Your code here.
    		}
    	}
    	catch(pError){}
    Last edited by jlizarraga; 03-13-2009 at 07:02 AM. Reason: resolved

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,375
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    Presumably, and in limited testing (In Safari 3 Win, and Google Chrome which support it, and in Opera 9, Fx 3, and IE 7 which do not), one would just need to test:

    Code:
    typeof document.documentElement.style.resize
    If supported, this will be 'string', otherwise 'undefined', so do like:

    Code:
    if(typeof document.documentElement.style.resize === 'string'){
     code here to take advantage of this property
    }
    The document.documentElement object is available for this sort of testing immediately after the opening html tag has been parsed, so this test may be used in the head of your document.
    - John
    ________________________

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

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

    jlizarraga (03-13-2009)

  4. #3
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default

    Wow did I over complicate that one! LOL

    Thanks John!

    EDIT: Wow, this page is the fifth result in google for "css3 resize".
    Last edited by jlizarraga; 03-13-2009 at 07:26 AM. Reason: google'd

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
  •