尝试这样的事情:
<div id="mydiv">
<span id="username">Alex</span> click on this div
</div>
<script>
$('#mydiv').click(function(){
window.open(' /chatwindow/?user='+$('#username').text(), '_blank', 'width=300,height=400');
return false;
});
</script>
或这个
<div id="mydiv">
Alex click on this div
</div>
<script>
var username = 'Alex';
$('#mydiv').click(function(){
window.open(' /chatwindow/?user='+username, '_blank', 'width=300,height=400');
return false;
});
</script>
或这个
<div id="mydiv">
Alex click on this div
<input type="hidden" name="username" value="Alex">
</div>
<script>
var username = 'Alex';
$('#mydiv').click(function(){
window.open(' /chatwindow/?user='+$('#mydiv > input[name="username"]').val(), '_blank', 'width=300,height=400');
return false;
});
</script>