문제

i want to load google +1 button only when needed,

<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
  {parsetags: 'explicit'}
</script>

so i was thinking of using jQuery.getScript() to do so like:

$.getScript('https://apis.google.com/js/plusone.js', function(data, textStatus){});

or

$.ajax({
  url: url,
  dataType: "script",
  success: success
});

but how can i pass the parsetags: 'explicit' param ?

도움이 되었습니까?

해결책

Well, dont bother, i found a solution:

$.ajax({
  url: "https://apis.google.com/js/plusone.js",
  dataType: "script",
  parameters: { parsetags: "explicit" }, 
  success: function () { gapi.plusone.go();  }
});

다른 팁

Set a global variable as follows, then load the g+ script:

window['___gcfg'] = { parsetags: 'explicit' };

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top