简体   繁体   English

输入值中的javascript变量

[英]javascript variable in input value

I have some problem. 我有一些问题。 This is my code snippets : 这是我的代码片段:

FB.api('/me', function(me){
  if (me.id) {
  alert(me.id);
  //alert(me.email);
  var fbmail = me.email;
  alert(fbmail);
  document.write('<input id="mail" type="hidden" value="'+fbmail+'">');                    
  var retro = document.getElementById('mail').value;
  alert(retro);                    
})

My problem is that there is no alert(retro); 我的问题是没有警报(复古); :( Can you tell me what's wrong??? :(你能告诉我什么是错的???

document.write can only be used while the page is loading. document.write只能在加载页面时使用。

Calling it in an async callback will erase the current page, so getElementById will return null. 在异步回调中调用它将擦除当前页面,因此getElementById将返回null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM