获取一个JQuery函数,在onLoad之后独立执行
可以通过将JQuery函数注入页面来执行它吗?无法将其附加到.ready函数。原因是用户将通过iframe上传图像。我需要JCrop在显示上传的图像后执行获取一个JQuery函数,在onLoad之后独立执行,jquery,function,execute,Jquery,Function,Execute,可以通过将JQuery函数注入页面来执行它吗?无法将其附加到.ready函数。原因是用户将通过iframe上传图像。我需要JCrop在显示上传的图像后执行 echo "<script>$('#pictures_step1_right_bottom1', window.parent.document).html('<img id=\"cropbox\" src=\"../../box/" . 'THM' . $filenameAlt . '.jpg' . "\">');&l
echo "<script>$('#pictures_step1_right_bottom1', window.parent.document).html('<img id=\"cropbox\" src=\"../../box/" . 'THM' . $filenameAlt . '.jpg' . "\">');</script>";
echo "<script>jQuery(function(){jQuery('#cropbox').Jcrop();});</script>";
使用javascript,您可以加载一个图像,并在加载完成后进行检查 这不是JQuery,而是普通的JS,但想法是一样的。目标是图像所在的位置。如果加载完成,函数将返回true,否则返回false。一旦这是真的,运行JCrop方法
document.getElementById( target ).complete
最后运行了一个计时器:
function checkPic() {
if($('#cropbox1').length != 0) {
jQuery(function() {
jQuery('#cropbox1').Jcrop();
});
}
timer(); // Check size again after 1 second
}
function timer() {
var myTimer = setTimeout('checkPic()', 3000); // Check size every 1 second}
}
checkPic();
function checkPic()
{
if($('#cropbox1').length != 0)
{
jQuery(function() { jQuery('#cropbox1').Jcrop(); });
}
timer(); // Check size again after 1 second
}
function timer()
{
var myTimer = setTimeout('checkPic()', 3000); // Check size every 1 second
}
最后运行了一个计时器:checkPic();函数checkPic(){if($('#cropbox1').length!=0){jQuery(函数(){jQuery('#cropbox1').Jcrop();})}timer()//1秒后再次检查大小}函数timer(){var myTimer=setTimeout('checkPic(),3000);//每1秒检查一次大小}