如何使用JavaScript将id设置为Session值

时间:2017-07-06 04:04:49

标签: javascript php

这是我的JavaScript代码,

Ext.Ajax.request

我想在此代码中将 function register_popup(id,name,msg) { for(var iii = 0; iii < popups.length; iii++) { //already registered. Bring it to front. if(id == popups[iii]) { Array.remove(popups, iii); popups.unshift(id); calculate_popups(); return; } } var element = '<div class="msg_box" style="right:290px" id="'+ id +'">'; element = element + '<div class="msg_head">'+ id +''; element = element + '<div class="close"><a href="javascript:close_popup(\''+ id +'\');">&#10005;</a></div></div>'; element = element +'<div class="msg_wrap"><div class="msg_body" class="msg-wgt-body"><ul id="chatlog"></ul>'+ msg+'<div class="msg_push" id="textmesage">dg</div></div><div class="msg_footer" ><textarea id="myTextArea" class="msg_input" rows="4" onkeypress="PushMessage(event , this);"+"\n"> </textarea></div></div>'; element = element + '<div><a href="get_message('+id+'","'+msg+');"></a></div>'; document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML + element; popups.unshift(id); calculate_popups(); } 设置为会话值。我是javascript的新手,请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

<script>
var someVal = <?php echo $_SESSION['some_var']; ?>;
</script>

应该这样做。