Recently, webIM is embedded in the OA system. Because WEBIM is on an independent page, multiple pages will appear if you click it multiple times. In this way, the server push will not recognize the page under ie6. so with the following code:
Copy codeThe Code is as follows:
<Script language = "javascript" type = "text/javascript">
Window. onload = function (){
If (GetCookie ("IsOpen") = ""){
SetCookie ("IsOpen", "1 ");
StartService ();
} Else {
Window. onunload = null;
Window. opener = null;
Window. open ("", "_ self ");
Window. close ();
}
} Window. onunload = function (){
If (GetCookie ("IsOpen ")! = "")
DeleteCookie ("IsOpen ");
}
Function GetCookieVal (offset ){
/// <Summary>
//// Obtain the cookie value whose name is offset
/// </Summary>
/// <Param name = "name"> Cookie name </param>
Var endstr = document. cookie. indexOf (";", offset );
If (endstr =-1)
Endstr = document. cookie. length;
Return unescape (document. cookie. substring (offset, endstr ));
}
Function GetCookie (name ){
/// <Summary>
/// Obtain the Cookie value by name
/// </Summary>
/// <Param name = "name"> Cookie name </param>
Var arg = name + "= ";
Var alen = arg. length;
Var clen = document. cookie. length;
Var I = 0;
While (I <clen ){
Var j = I + alen;
If (document. cookie. substring (I, j) = arg)
Return GetCookieVal (j );
I = document. cookie. indexOf ("", I) + 1;
If (I = 0) break;
}
Return "";
}
Function SetCookie (name, value ){
/// <Summary>
/// Set Cookie
/// </Summary>
/// <Param name = "name"> Cookie name </param>
/// <Param name = "value"> Cookie value </param>
Var argc = SetCookie. arguments. length;
Var argv = SetCookie. arguments;
Var path = (argc> 3 )? Argv [3]: null;
Var domain = (argc> 4 )? Argv [4]: null;
Var secure = (argc> 5 )? Argv [5]: false;
Document. cookie = name + "=" + value +
(Path = null )? "": ("; Path =" + path) +
(Domain = null )? "": ("; Domain =" + domain) +
(Secure = true )? "; Secure ":"");
}
Function DeleteCookie (name ){
/// <Summary>
/// Delete a Cookie
/// </Summary>
/// <Param name = "name"> Cookie name </param>
Var exp = new Date ();
Exp. setTime (exp. getTime ()-1 );
Var cval = GetCookie (name );
Document. cookie = name + "=" + cval + "; expires =" + exp. toGMTString ();
}
</Script>
Put the above Code under the head. Is it easy enough? Of course, the above Code mainly solves the problem of opening a page with a hyperlink. If it is a page opened by window. open, it is simpler. The Code is as follows:
Copy codeThe Code is as follows:
Var win = null; // define a variable to judge.
If (win = null)
{
Win = window. open ("Main. aspx", '', strfeatures );
}