Forum Moderators: open
i've been working on v3chat and integrate on my smf board
on the instruction:
i put this code inside <head> tag of my index template
<script language="JavaScript"><!--
var userName = "', $context['user']['name'], '";
var userID = "', $context['user']['id'], '";
// --></script>
<script language="JavaScript" type="text/javascript" src="http://www.YOURWEBSITE.com/chat/chat.js"></script> then inside the <body> tag
i put this button some of my page
<a href="#" onClick="launchChat();return false;">Chat</a> what i want is,i want to embed this on my page,i dont want to have a button that need to click to access on tha chatroom
here is the chat.js code... what im gonna do?
function launchChat()
{
var xOffSet = (screen.width - 225) / 2;
var yOffSet = (screen.height - 500) / 2;
var features = 'width=600,height=488,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0';
var winName = 'v3chatrooms';
var chatUrl = 'http://localhost/test/forum/chat/index.php?uid='+userID+'&uname='+userName;
myWin = window.open(chatUrl,winName,features);
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
createCookie('login','login',1);
}
sorry for my english
thanks in advance....
what i want is,i want to embed this on my page,i dont want to have a button that need to click to access on tha chatroom
<body onLoad="launchChat()">
Which may get blocked by some browsers, but you could add this to your Javascript block (note that the language attribute is not needed:)
<script type="text/javascript">
var userName = "', $context['user']['name'], '";
var userID = "', $context['user']['id'], '";
window.onload=function() { launchChat(); };
</script>
<script type="text/javascript" src="http://www.YOURWEBSITE.com/chat/chat.js"></script>
A small improvement on your new window attributes:
- You do not need to specify "=0" for features you want to exclude. Just don't include them in the list.
- Don't ever specify no scrollbars or remove resizability. You never know your user's environment; although it sizes perfectly in your browser, if someone has say, a large text size set, or a different resolution than you are using, the content will get pushed outside the "frame" of your new window and they won't be able to access vital controls, like submit buttons.
So the below will not include anything you've set to "0," but WILL include scrollbars if they are needed and be resizable:
var features = 'width=600,height=488,scrollbars,resizable';