2015-01-27 26 views
3

首先,此代碼適用於除IE 10以外的所有瀏覽器。我只是想使用Google Sign Up Javascript SDK來讓用戶註冊網站。下面是代碼:谷歌在Internet Explorer中註冊不起作用

function SignInCallback(authResult) { 
    if (authResult['status']['signed_in']) { 
     gapi.client.load('plus', 'v1', apiClientLoaded); 
    } else { 
     // "immediate_failed" - Could not automatically log in the user 
    } 
} 

function apiClientLoaded() { 
    gapi.client.plus.people.get({ 
     userId: 'me' 
    }).execute(handleEmailResponse); 
} 

function handleEmailResponse(resp) { 
    var s = resp.emails[0].value; 
} 

如可以從代碼中可以看出,回調函數是SignInCallback。然後調用apiClientLoaded,然後將用戶詳細信息的響應傳遞給handleEmailResponse。但在IE中,當我嘗試評估resp.emails[0].value;時,出現以下錯誤:SCRIPT5007: Unable to get property '0' of undefined or null reference。如前所述,由於某種原因,除了IE 10以外,其他所有瀏覽器都可以使用此功能任何想法爲什麼?

+0

是在兼容模式下的頁面呈現? – 2015-01-27 07:16:56

+0

它沒有在兼容模式下運行,因爲當這種情況發生時,它會從字面上抱怨一切......感嘆 – user481610 2015-01-27 10:09:57

回答

0

嘗試setting the document mode to IE 8 standards爲您的網頁:

<!-- Use IE 8 Standards mode --> 
<meta http-equiv="x-ua-compatible" content="IE=8" /> 

你甚至可能要強制IE模仿版本8,更具體的做法:

<!-- Use Emulated IE 8 Standards mode --> 
<meta http-equiv="x-ua-compatible" content="IE=EmulateIE8" /> 
相關問題