www.webdeveloper.com
Results 1 to 4 of 4

Thread: Javascript funny code?

  1. #1
    Join Date
    Jul 2012
    Posts
    2

    Javascript funny code?

    Following lines of code are used to put 'KeepAlive.aspx as a dummy page in the website.


    var img = new Image(1, 1);
    img.src = 'KeepAlive.aspx?date=' + escape(new Date());

    I do not understand that. What is image(1,1) two dimensional array of images? How come image has src property?

    The code has been taken from
    http://www.codeproject.com/Articles/...out-in-ASP-Net

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    The parameters specify the dimensions of the image, but in this case are unnecessary.
    The code could be written:
    Code:
    new Image().src = 'KeepAlive.aspx?date=' + escape(new Date());

  3. #3
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,774

  4. #4
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by toicontien View Post
    Some browsers might not make the HTTP request for the image until it is appended to the document.
    That may apply when you create an <img> element, but not to an Image() object. Otherwise pre-loaders would not work.

Thread Information

Users Browsing this Thread

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

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