Should be easier than I thought, as it's opening a true window. If you want it to open in an iframe, just edit chat.js to look like so (change highlighted):
Code:
function launchChat()
{
var xOffSet = (screen.width - 225) / 2;
var yOffSet = (screen.height - 500) / 2;
var features = 'width=900,height=700,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1';
var winName = 'prochatrooms';
var chatUrl = 'http://'+location.hostname+'/prochatrooms/index.php?uid='+userID+'&uname='+userName+'&room='+roomID;
myWin = window.open(chatUrl,winName);
function createCoo . . .
Place an iframe on your page:
Code:
<iframe name="prochatrooms" src="about:blank" width="300" height="300" scrolling="auto" frameborder="1"></iframe>
The highlighted part is important, the width and height are up to you to determine. The src can be any page, or left as "about:blank", whatever you use there will be displayed to the user unless and until they launch the chat. Scrolling should probably be left as auto, but may be changed to "yes" or "no". The only other option for frameborder is 0 for no border, though ordinary css style may be used to control the border, position, and many other properties of the iframe element. Editing the prochatrooms/index.php file may be required for certain things.
To give the user the opportunity to click on a button or link to launch chat, just give that button or link this event attribute:
Code:
onclick="launchChat();return false;"
example:
Code:
<a href="#" onclick="launchChat();return false;">Chat</a>
But unless you remove:
Code:
window.onload=function() { launchChat(); };
the chat (assuming we've done this right) will load in the iframe on page load anyway.
Now, if you want the chat to take over the entire page. That's even easier, just change (in chat.js again):
Code:
function launchChat()
{
var xOffSet = (screen.width - 225) / 2;
var yOffSet = (screen.height - 500) / 2;
var features = 'width=900,height=700,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1';
var winName = 'prochatrooms';
var chatUrl = 'http://'+location.hostname+'/prochatrooms/index.php?uid='+userID+'&uname='+userName+'&room='+roomID;
window.location.replace(chatUrl);
function createCoo . . .
But if you do that, the cookie will probably not get set, so you would want to put that part first in the code:
Code:
function launchChat()
{
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);
var xOffSet = (screen.width - 225) / 2;
var yOffSet = (screen.height - 500) / 2;
var features = 'width=900,height=700,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1';
var winName = 'prochatrooms';
var chatUrl = 'http://'+location.hostname+'/prochatrooms/index.php?uid='+userID+'&uname='+userName+'&room='+roomID;
window.location.replace(chatUrl);
}
There may be a link or button on the prochatrooms/index.php page that is for closing chat. You may want to remove it or change it. If you are having the chat take over the window (as opposed to launch in an iframe) you may want to change it to have an event such as:
Code:
onclick="history.go(-1);return false;"
Bookmarks