开发者

Need setOnLoadCallback() Alternative

开发者 https://www.devze.com 2023-02-19 02:56 出处:网络
I\'m working on an internal site, and cannot make an external call to Google\'s API to use their setOnLoadCallback() function, and can\'t seem to find any pure JQuery alternatives that I can use with

I'm working on an internal site, and cannot make an external call to Google's API to use their setOnLoadCallback() function, and can't seem to find any pure JQuery alternatives that I can use with my locally-called JQuery. For reference, here's the code I'm trying to implement, but the original developer wrote it using the Google API:

<script type="text/javascript">

  google.load("jquery", "1.3.2");

  google.load("jqueryui", "1.7.2");



  google.setOnLoadCallback(function() { 

    var timeout = null;

    var initialMargin = parseInt($("#siteMenuBar").css("margin-top"));



    $("#siteMenuBar").hover(

        function() {

            if (timeout) {

                clearTimeout(timeout);

                timeout = null;

            }

            $(this).animate({ marginTop: 0 }, 'fast');

        },

        function() {

            var menuBar = $(this);

            timeout = setTimeout(function() {

                timeout = null;

           开发者_Go百科     menuBar.animate({ marginTop: initialMargin }, 'slow');

            }, 1000);

        }

    );

  });

</script>

Any suggestions/ideas are appreciated.


I think all you would need is replace

google.setOnLoadCallback(function() { 

with

$(document).ready(function() {

I hope this helps !

0

精彩评论

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

关注公众号