Sunday, 15 August 2010

javascript - Chrome - Image not loaded when loading from JS -



javascript - Chrome - Image not loaded when loading from JS -

i trying load image on page load.

when utilize simple src works ok:

<img src="url.png" />

but when seek load js not load:

<img id="loadimage" src="" />

js:

var _img = document.getelementbyid('loadimage'); _img.src = 'url.png';

the url shown 'not found'.

i getting same error in post : what status=canceled resource mean in chrome developer tools?

i cant seem solve it, why happening.

why don't seek , save whole image tag in variable? you not providing invalid html markup empty src.

just alter html to

<div id="imageholder"></div>

and utilize code

$(document).ready(function() { var image_1 = $('<img src="img/url.png" />'); $("#imageholder").append(image_1); });

take fiddle , seek :)

http://jsfiddle.net/abf67/ note: i'm using jquery illustration :)

javascript jquery html

No comments:

Post a Comment