Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不安全的JavaScript试图访问URL为的帧关于:从URL为的帧为空_Javascript_Javascript Events_Google Api - Fatal编程技术网

不安全的JavaScript试图访问URL为的帧关于:从URL为的帧为空

不安全的JavaScript试图访问URL为的帧关于:从URL为的帧为空,javascript,javascript-events,google-api,Javascript,Javascript Events,Google Api,我正在使用GoogleContactsJavaScriptAPI。我正在尝试使用中给出的代码将联系人添加到经过身份验证的用户的gmail帐户中 我可以登录和注销。但是我尝试创建一个新联系人,我的chrome出现了一个错误。我在AmazonS3存储桶中托管了javascript和html文件,还有图像 不安全的JavaScript试图访问URL为的帧关于:从URL为的帧为空。域、协议和端口必须匹配 并且不会创建联系人 HTML文件 <!DOCTYPE HTML> <head&g

我正在使用GoogleContactsJavaScriptAPI。我正在尝试使用中给出的代码将联系人添加到经过身份验证的用户的gmail帐户中

我可以登录和注销。但是我尝试创建一个新联系人,我的chrome出现了一个错误。我在AmazonS3存储桶中托管了javascript和html文件,还有图像

不安全的JavaScript试图访问URL为的帧关于:从URL为的帧为空。域、协议和端口必须匹配

并且不会创建联系人

HTML文件

<!DOCTYPE HTML>
<head> <title> Google contacts </title> 
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="auth.js" > </script>
</head>

<body>
<h1> Google contacts </h1>
<img src="rss_icon.jpg" width="100" height="100" />
<input type="button" value="login" onclick="logMeIn()" />
<input type="button" value="logout" onclick="logMeOut()" />
<input type="button" value="createContact" onclick="createContact()" />

</body>
</html>

你试过把
google.load('gdata','1.x')在html文件中


这对我很有效。

问题是我从http服务器访问https服务器,所以协议不匹配只是更改了feedURi';到
';

我正在处理一个类似的问题(参见)。我发现,如果在尝试更改另一帧之前添加几秒钟的延迟,“about:blank”解析为一个好看的URL。不过还是有同样的错误!
google.load( 'gdata', '1.x' );

 var contactsService;

function setupContactsService() {
  contactsService = new google.gdata.contacts.ContactsService('GoogleInc-jsguide-1.0');
}

function logMeIn() {
  var scope = 'https://www.google.com/m8/feeds';
  var token = google.accounts.user.login(scope);
}


function logMeOut() {
  google.accounts.user.logout();
}

function createContact() {

/*
 * Create a contact entry
 */ 

// Create the contacts service object
var contactsService =
    new google.gdata.contacts.ContactsService('GoogleInc-jsguide-1.0');

// The feed URI that is used to create a contact entry
var feedUri = 'http://www.google.com/m8/feeds/contacts/default/full';

// Create an instance of ContactEntry
var entry = new google.gdata.contacts.ContactEntry();

// Set the name of the contact
entry.setTitle(google.gdata.Text.create('JS-Client: Create Contact'));

// Set the content of the contact
entry.setContent(google.gdata.Text.create('content info here'));

// Create an email instance
var email = new google.gdata.Email();
email.setAddress('JS-Client@domain.com');
email.setPrimary(true);
// Designate this email as the "home" email
email.setRel(google.gdata.Email.REL_HOME);

// Add the email instance
entry.setEmailAddresses([email]);

// The callback method that will be called after a successful insertion from insertEntry()
var callback = function(result) {
  PRINT('contact entry created!');
}

// Error handler will be invoked if there is an error from insertEntry()
var handleError = function(error) {
  document.getWriter='error';
}

// Submit the request using the contacts service object
contactsService.insertEntry(feedUri, entry, callback, 
    handleError, google.gdata.contacts.ContactEntry);
    }