www.webdeveloper.com
Results 1 to 3 of 3

Thread: i dont know what im doing wrong

  1. #1
    Join Date
    Dec 2010
    Posts
    2

    i dont know what im doing wrong

    i dont know what im doing wrong with this code,
    if you guys can help me please do.
    the folowing code always gives the alert even when i dont need it.


    var scrlWidth= document.getElementById("scrlArea");
    var makeMeScrollable= document.getElementById("makeMeScrollable");

    alert(scrlWidth.style.width); // it says: 2371px
    alert(makeMeScrollable.offsetWidth+"px"); // it says: 601px
    if ( scrlWidth.style.width < makeMeScrollable.offsetWidth+"px" )
    {
    alert("smaller")
    }

    Dave.

  2. #2
    Join Date
    Aug 2009
    Posts
    593
    Code:
    var scrlWidth = document.getElementById("scrlArea");
    var makeMeScrollable = document.getElementById("makeMeScrollable");
    
    alert(scrlWidth.offsetWidth);
    alert(makeMeScrollable.offsetWidth);
    
    if (scrlWidth.offsetWidth < makeMeScrollable.offsetWidth) {
    	alert("smaller")
    }
    I haven't tested this, but you were comparing strings before possibly giving you undesired results.
    Last edited by thraddash; 12-14-2010 at 04:59 AM.

  3. #3
    Join Date
    Dec 2010
    Posts
    2
    I think I know what im doing wrong .
    i need the width value without the px at the end.

    thx for your reply =D

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles