Parker Software Ltd Homepage
Forum Home Forum Home > WhosOn Live Chat > FAQ's > Advanced FAQ's
  New Posts New Posts RSS Feed - Code that doesn't use document.write
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Code that doesn't use document.write

 Post Reply Post Reply
Author
Message
Daniel View Drop Down
Admin Group
Admin Group
Avatar
Technical Director

Joined: 19 Dec 2006
Location: Stoke-on-Trent
Points: 881
Post Options Post Options   Thanks (0) Thanks(0)   Quote Daniel Quote  Post ReplyReply Direct Link To This Post Topic: Code that doesn't use document.write
    Posted: 30 Jun 2008 at 9:44am
 
preparation:
3 images:
blank_whoson.gif - placeholder image the same size as online / offline
online.gif - image for online
offline.gif - image for offline
 
If you wish, online and offline can be pre-cached to enable faster checking of the status.
 
 
code in page:
(chat link location)
 <a id='whoson_a'> 
  <img id='whoson_image' width='{width}' height='{height}' src='images/blank_whoson.gif' /> 
</a> 
 
(bottom)
<script type='text/javascript' lang='Javascript' src='scripts/whoson.js'></script> 
<script type='text/javascript' lang='Javascript' src='http://{gatewayaddress}/invite.js?domain={domain}'></script>
  
file:  scripts/whoson.js
// ==============================================================================
// WhosOn LiveStats & Chat Gateway script http://www.whoson.com
// ==============================================================================
// This script should be placed in the root directory of your web site. It should
// be included in each page you want to track.
// Place the Include on your page at the place where you want the Click-To-Chat
// graphic to appear.
// ===============================================================================
var sWOGateway       = "{gatewayaddress}";    // specify the external address:port of the WhosOn Gateway server
var sWOGatewaySSL    = "{gatewayssladdress}"; // specify the external address:port of the WhosOn Gateway server SSL interface
var sWODomain        = "{domain}";  // the domain you are monitoring
var sWODepartment    = ""; // optional department
var sWOChatstart     = "{chaturl}"; // url to the chatstart.htm page
var sWOLanguage      = ""; // language for the chat window
var sWOBackgroundURL = ""; // optional custom background url
var sWOResponse      = "Y"; // set to a blank string if you do NOT want a visible chat link
var sWOInvite        = "Y";  // set to a blank string if you do NOT want invite requests to be polled
var sWOPreselect     = ""; // set to D to pre-select Department before starting chat, O to pre-select Operator
var sWOSession;
var sWOUrl;
var sWOUser="";
var sWOPage="";
var sWOProtocol=window.location.protocol;
// specify a user name here if you want a specific user name instead of a session cookie
// sWOUser="my user";
// specify a page name here if you want a specific page name shown in WhosOn instead of the window.location
// sWOPage="my page";
var sWOCost=0;    // specify a visit cost
var sWORevenue=0; // specify the revenue generated by the visitor
// optional contact information. Specify values for these variables if you want contact info for the visitor passed to WhosOn
var sWOName="";
var sWOCompany="";
var sWOEmail="";
var sWOTelephone="";
function sWOImageLoad()
{
 if (sWOResponse == ""){
  return;
 }
 
 sWOChatstart+="?domain="+sWODomain+"&lang="+sWOLanguage;
 if(sWOBackgroundURL!="")sWOChatstart+="&bg="+sWOBackgroundURL;
 if(sWODepartment.length>0)sWOChatstart+="&dept="+escape(sWODepartment);
 if(sWOPreselect.length>0)sWOChatstart+="&select="+sWOPreselect;
 
 // image has loaded, let us look at it's size.
 if (sWOImage.height == 1)
 {
  // no one is home
  document.getElementById('whoson_image').src = "/images/offline.gif"
 }
 else
 {
  document.getElementById('whoson_image').src = "/images/online.gif";
 }
  
  document.getElementById('whoson_a').href = sWOChatstart;
}
var sWOImage = new Image();
sWOImage.onload = sWOImageLoad;

if(sWOUser==""){
 // create a unique session cookie for the visitor
 var dt=new Date();
 var sWOCookie=document.cookie.toString();
 if(sWOCookie.indexOf("whoson")==-1){
  sWOSession=parseInt(Math.random()*1000)+"-"+dt.getTime();
  document.cookie="whoson="+sWOSession+";expires=Fri, 31-Dec-2010 00:00:00 GMT;";
 }
 sWOCookie=document.cookie.toString();
 if(sWOCookie.indexOf('whoson')==-1){
  sWOSession="";
 } else {
  var s=sWOCookie.indexOf("whoson=")+7;
  var e=sWOCookie.indexOf(";",s);
  if(e==-1)e=sWOCookie.length;
  sWOSession=sWOCookie.substring(s,e);
 }
}
if(sWOProtocol=="https:")sWOGateway=sWOGatewaySSL;
if(sWOUser!="")sWOSession=sWOUser;
if(sWOPage=="")sWOPage=escape(window.location);
if(sWOProtocol=="file:")sWOProtocol="http:";
sWOUrl=sWOProtocol+"//"+sWOGateway+"/stat.gif?u="+sWOSession+"&d="+sWODomain;
if(sWODepartment.length>0)sWOUrl+="&t="+escape(sWODepartment);
sWOUrl+="&p='"+sWOPage+"'&r='"+escape(document.referrer)+"'";
if(sWOCost!=0)sWOUrl+="&c="+sWOCost;
if(sWORevenue!=0)sWOUrl+="&v="+sWORevenue;
if(sWOName!="" || sWOCompany!="" || sWOEmail!="" || sWOTelephone!="")sWOUrl+="&n="+sWOName+"|"+sWOCompany+"|"+sWOEmail+"|"+sWOTelephone;
if(sWOResponse==""){
 sWOImage.src = sWOUrl;
} else {
 sWOUrl+="&response=g";
 sWOImage.src = sWOUrl;
}


Edited by Daniel - 30 Jun 2008 at 10:04am
Daniel Tallentire
Support
Parker Software
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.05
Copyright ©2001-2016 Web Wiz Ltd.

This page was generated in 0.193 seconds.