Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder bigtiger's Avatar
    Join Date
    Oct 2005
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question A simple question about javascript ?

    Code:
    function update()
    {
    	var photoMgt = new PhotoManager();
    	photoMgt.create_image("http://localhost/1.jpg");	/* this works */
    	photoMgt.add("http://localhost/1.jpg");			/* but this not */
    }
    
    function PhotoManager()
    {
    	this.idx = 0;
    	this.image_ary = new Array();
    	this.add = add;
    	this.create_image = create_image;
    }
    
    function add(url)
    {
    	if (typeof(url) == 'string' && (url.indexOf("http://") == 0))
    	{
    		if (this.create_image(url))
    		{
    			return true;
    		}
    		else
    		{
    			return false;
    		}
    	}
    }
    
    function create_image(url)
    {
    	alert(this.idx);			/* directly called with create_image will work, but will add function will not */
    	var im = new Image();
    	if ((im) && (im.tagName.toLowerCase() == 'img'))
    	{
    		with (im)
    		{
    			src = url;
    			border = 0;
    		}
    		this.image_ary.push(im);
    		return true;
    	}
    	return false;
    }
    hi, I have this simple question is here not way to make this indirectly reference variable ?

    Thanks you,
    Last edited by bigtiger; 10-21-2006 at 01:41 PM.

  • #2
    New Coder bigtiger's Avatar
    Join Date
    Oct 2005
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'am got remember I can have to use push method as alternate but still can't access the image_ary. any help would be appreciate.

    Thanks you
    Last edited by bigtiger; 10-21-2006 at 09:46 AM.


  •  

    Posting Permissions

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