Why does google.load cause my page to go blank?

前端 未结 5 1768
花落未央
花落未央 2020-11-29 02:45

Well, this looks strange but I\'m not able to find a solution.

Why in the world does this fiddle http://jsfiddle.net/carlesso/PKkFf/ show the page content and, then

5条回答
  •  旧巷少年郎
    2020-11-29 02:57

    You just have to define a callback, and it will not clear the page (maybe the older versions of google.load() did, but apparently the new ones do not if used with callback). Here a simplified example when I'm loading the "google.charts" lib:

    if(google) {
        google.load('visualization', '1.0', {
            packages: ['corechart'],
            callback: function() {
                // do stuff, if you wan't - it doesn't matter, because the page isn't blank!
            }
        } )
    }
    

    When doing it whitout callback(), I still get the blank page too - but with callback, it's fixed for me.

提交回复
热议问题