如何在用户按下按钮或图像后显示Google Picker API对话框? [英] How to show the Google Picker API dialog after user presses a button or an image?

查看:121
本文介绍了如何在用户按下按钮或图像后显示Google Picker API对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有谁可以帮助我的HTML专家?



我想要显示 Google Picker API对话框,用户点击按钮或图像后,我想在页面上显示结果。对于知道如何进行网络编程的开发人员来说,这应该很简单。

如何使用示例代码位于上面的链接中。非常感谢。

解决方案

我现在自己解决了。
Google Javascript API的主要加载器是Google Loader。



请看这里的文档: http://code.google.com/intl/zh-CN/apis/loader/



将此代码插入< head> ...(< / head> )(HTML文件选取器)。点击选择器后加载的主要功能是 newPicker()。它会将其加载到选取器中,并设置处理选取器的第一个回调函数。

 < script src =http:// www .google.com / JSAPI>< /脚本> 
< script type =text / javascript>

Google Google Picker API导入
函数newPicker(){
google.load('picker','1',{callback:createPicker} );
}

//创建并呈现Picker对象来选择文档
function createPicker(){
var picker = new google.picker.PickerBuilder()。
addView(google.picker.ViewId.DOCUMENTS)。
setCallback(pickerCallback)。
build();
picker.setVisible(true);
}

//一个简单的回调实现,它将一些ID设置为选择器值。
函数pickerCallback(data){
if(data.action == google.picker.Action.PICKED){
document.getElementById('gdocs_resource_id')。value = google.picker.ResourceId .generate(data.docs [0]);
document.getElementById('gdocs_access_token')。value = data.docs [0] .accessToken;
}
}
< / script>

HTML中的链接:

 < a href =javascript:newPicker()style =font-weight:bold>从Google文档导入< / a> 

当用户点击HTML链接时,将显示选择器。


is any HTML expert out there who can help me?

I want to show the Google Picker API Dialog after the user clicks on a button or an image and I want to show the result on the page afterwards. It should be simple for developers who know how to do web programming.

Sample code of how to use is in the link above. Big thanks.

解决方案

I now solved it myself. The main loader of Google Javascript APIs is the Google Loader.

Look here at the documentation: http://code.google.com/intl/en/apis/loader/

Insert this code inside <head> ... </head> of the HTML (a Google Docs Picker). The main function for loading after a click picker is newPicker() . It loads it the picker and sets the first callback for handling the picker.

<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">   

    // Google Picker API for the Google Docs import
    function newPicker() {
        google.load('picker', '1', {"callback" : createPicker});
    }       

    // Create and render a Picker object for selecting documents
    function createPicker() {
        var picker = new google.picker.PickerBuilder().
            addView(google.picker.ViewId.DOCUMENTS).
            setCallback(pickerCallback).
            build();
        picker.setVisible(true);
    }

    // A simple callback implementation which sets some ids to the picker values.
    function pickerCallback(data) {
        if(data.action == google.picker.Action.PICKED){
            document.getElementById('gdocs_resource_id').value = google.picker.ResourceId.generate(data.docs[0]);
            document.getElementById('gdocs_access_token').value = data.docs[0].accessToken;                  
        }
    }    
 </script>

Link in HTML:

<a href="javascript:newPicker()" style="font-weight: bold">Import from your Google Docs</a>

When the user clicks on the HTML link the picker will be shown.

这篇关于如何在用户按下按钮或图像后显示Google Picker API对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆