1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

IMG display in 0/0 Width/Height issue

Discussion in 'C#' started by mongkb, Jul 23, 2006.

  1. #1
    Hi guys, I have a problem about displaying some IMGs in my asp code:

    JavaScript:
    function chkTmbSize(id) {
    var h = id.height;
    var w = id.width;
    id.resize = true;
    if (h>w) {
    id.width = 30 / id.height * id.width;
    id.height = 30;
    }
    else {
    id.height = 40 / id.width * id.height;
    id.width = 40;
    }
    }

    Codes:
    <% Response.Buffer = True %>
    .....
    <IMG ID="thumb" SRC="<%=tImg%>" Onload="chkTmbSize(this);">


    the code works without error but just SOMETIMES it display the IMG
    in 0,0 width/height in a FOR/NEXT loop, but after refresh the page,
    the IMG will be showed correctly. Could you please help to solve this
    problem, and sorry for my poor English, thanks in advance.
     
    mongkb, Jul 23, 2006 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    instead of putting the onload per <img onload event, put a loop in javascript in the head of the document. Then put an onload event handler in the body tag. This can run through all items that you wrote with your asp code... So essentially, write the list of your images in the javascript function to check for, then you only need one js function call
     
    ccoonen, Jul 24, 2006 IP