开发者

How to detect javascript file download complete in the client machine by simple javascript

i hard that it is always better to move all script at the bottom of the page and as a result page load very fast. so today i did that and found a problem that when javascript files and my javascript function was loading then i click on a button which was attached with jquery function. the result i got page reload. which i don't want. to avoid this situation we have 2 choice. one is let all script tag should be download first before other page content download and second one is just detect javascript file or script tag download in client side and function开发者_开发问答s are ready to call. if javascript files are downloading and function can be called then button click should call the righ js function other wise it will return false.

here is my code

if btnFeedback1 is clicked then a routine will be executed.

<script language="javascript" type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function () {
    jQuery("#btnFeedback1").click(function () {
        //here my logic goes
        return false;
    });
});

if associated js file are downloading then button click will return false not reload the page. so please guide me with code how to achieve it.


<input type="button" onclick="return false;" value="CLick button" id="btnFeedback1" />

And javascript

<script language="javascript" type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function () {
    $("#btnFeedback1").removeAttr('onclick');
    $("#btnFeedback1").click(function () {
        //here my logic goes
        return false;
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜