Skip to content

Chat in popup window

Philip Nicolcev edited this page Nov 8, 2013 · 3 revisions

How to open the chat in a popup window

To access the chat you just need a link to the chat directory.
To open a link in a new window with a predefined size centered on the screen (and without location/menu/toolbar) you just need JavaScript.

Add the following code to the head of all pages displaying the chat link (the template file used for the header):

<script type="text/javascript">
	// <![CDATA[
		function openWindow(url,width,height,options,name) {
			width = width ? width : 800;
			height = height ? height : 600;
			options = options ? options : 'resizable=yes';
			name = name ? name : 'openWindow';
			window.open(
				url,
				name,
				'screenX='+(screen.width-width)/2+',screenY='+(screen.height-height)/2+',width='+width+',height='+height+','+options
			)
		}
	// ]]>
</script>

Adjust the link to the chat using the function defined above:

<a href="chat/" onclick="openWindow(this.href);this.blur();return false;">Chat</a>

This will open the chat window with a width of 800px and a height of 600px centered on the screen and without locationbar, toolbar or menubar. It will still be resizable, so users can decide to use the full width of their screen.

To open the chat window with a different size you would use the following link:

<a href="chat/" onclick="openWindow(this.href,1024,768);this.blur();return false;">Chat</a>