此测试(发送或不发送跨域AJAX)在Internet Explorer上始终为false,但它适用于Microsoft Edge。
看起来,<a>
元素不会填充在IE上。
function testSameOrigin(url){
/*
Return true if belongs to the same origin
*/
var loc = window.location,
a = document.createElement('a');
a.href = url;
return a.hostname == loc.hostname &&
a.port == loc.port &&
a.protocol == loc.protocol;
}
我该如何解决这个问题?
感谢您的帮助。
答案 0 :(得分:0)
我解决了这个问题:
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String messageType = gcm.getMessageType(intent);
if (!extras.isEmpty()) {
if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
.equals(messageType)) {
sendNotification(false,"Send error: " + extras.toString(),null,null,null);
} else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED
.equals(messageType)) {
sendNotification(false,"Deleted messages on server: "
+ extras.toString(),null,null,null);
} else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE
.equals(messageType)) {
// sendNotification("Message Received from Google GCM Server:\n\n"
// + extras.get(ApplicationConstants.MSG_KEY));
String name=extras.getString("name");
String address=extras.getString("address");;
sendNotification(true,name,address);
}
}
GcmBroadcastReceiver.completeWakefulIntent(intent);
}
This post帮助我找到自己的方式。