javascript - Creating an iframe from JQuery - properties are not working, why not? -


hello im creating iframe in javascript. style , loaded event doesnt seem work. doing wrong?

var iframe = $("<iframe src='/player/showpage/"+data.pageid+"'/>", {                             style: "position:absolute; left:-100%",                             load: function () {                                 var = this;                                 $(this).animate({                                     left: 0                                 }, 500);                                 $('iframe').not(this).animate({                                     left: '-100%'                                 }, 500, function () {                                     $('iframe').not(that).remove();                                 });                             }                         });                         $('body').append(iframe); 

i must missing something, cant figure out is. iframe sitting there - mocking me - on screen...

you need move 'src' object literal , works fine.

var iframe = $("<iframe>", {     src: '/player/showpage/' + data.pageid,     style: "position:absolute; left:-100%",     load: function () {         var = this;         $(this).animate({             left: 0         }, 500);         $('iframe').not(this).animate({             left: '-100%'         }, 500, function () {             $('iframe').not(that).remove();         });     } }); $('body').append(iframe); 

please check jsfiddle working demo.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -