Html 如何在弹出窗口中进行聊天

Html 如何在弹出窗口中进行聊天,html,Html,我正在使用zoho在我的网站上进行实时聊天。如何获得通常出现在大多数网站上的弹出窗口 它的代码是这样的 <div style="height:300px; width:300px; padding-top:20px;"><iframe style='overflow:hidden;width:100%;height:100%;' frameborder='0' border='0' src='http://chat.zoho.com/mychat.sas?U=c36599

我正在使用zoho在我的网站上进行实时聊天。如何获得通常出现在大多数网站上的弹出窗口

它的代码是这样的

   <div style="height:300px; width:300px; padding-top:20px;"><iframe style='overflow:hidden;width:100%;height:100%;' frameborder='0' border='0' src='http://chat.zoho.com/mychat.sas?U=c36599f3bbee3974d1af8b95ee04001b&chaturl=helpdesk&V=********************Center&smiley=false'></iframe></div>

如何确保此iframe必须加载到弹出窗口中。

请尝试使用window.open

window.open("http://chat.zoho.com/mychat.sas?U=c36599f3bbee3974d1af8b95ee04001b&chaturl=helpdesk&V=********************Center&smiley=false","mywindow","location=1,status=1,scrollbars=1,width=100,height=150");

将页面加载事件添加到弹出窗口

<body onLoad="window.open('http://chat.zoho.com/mychat.sas?U=c36599f3bbee3974d1af8b95ee04001b&chaturl=helpdesk&V=********************Center&smiley=false','mywindow','location=1,status=1,scrollbars=1,width=100,height=150');">


`以下是对我有效的完整解决方案

HTML代码:----chat.HTML包含我从zoho获得的代码

Click<a href="chat.html"  style="padding-left:0px;"rel="popup console 350 350">here</a> to chat with us
Javascript代码

function addEvent(elm, evType, fn, useCapture){if(elm.addEventListener){elm.addEventListener(evType, fn, useCapture);return true;}else if (elm.attachEvent){var r = elm.attachEvent('on' + evType, fn);return r;}else{elm['on' + evType] = fn;}}


var newWindow = null;

function closeWin(){
if (newWindow != null){
    if(!newWindow.closed)
        newWindow.close();
}
}

function popUpWin(url, type, strWidth, strHeight){

closeWin();

type = type.toLowerCase();

if (type == "fullscreen"){
    strWidth = screen.availWidth;
    strHeight = screen.availHeight;
}
var tools="";
if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
newWindow = window.open(url, 'newWin', tools);
newWindow.focus();
}

function doPopUp(e)
{
 //set defaults - if nothing in rel attrib, these will be used
var t = "standard";
  var w = "780";
 var h = "580";
 //look for parameters
  attribs = this.rel.split(" ");
 if (attribs[1]!=null) {t = attribs[1];}
  if (attribs[2]!=null) {w = attribs[2];}
  if (attribs[3]!=null) {h = attribs[3];}
  //call the popup script
  popUpWin(this.href,t,w,h);
  //cancel the default link action if pop-up activated
  if (window.event) 
    {
window.event.returnValue = false;
window.event.cancelBubble = true;
} 
  else if (e) 
{
e.stopPropagation();
e.preventDefault();
}
  }

  function findPopUps()
   {
   var popups = document.getElementsByTagName("a");
   for (i=0;i<popups.length;i++)
{
if (popups[i].rel.indexOf("popup")!=-1)
    {
    // attach popup behaviour
    popups[i].onclick = doPopUp;
    // add popup indicator
    if (popups[i].rel.indexOf("noicon")==-1)
        {
        popups[i].style.backgroundImage = "url(pop-up.gif)";
        popups[i].style.backgroundPosition = "0 center";
        popups[i].style.backgroundRepeat = "no-repeat";
        popups[i].style.paddingLeft = "3px";
        }
    // add info to title attribute to alert fact that it's a pop-up window
    popups[i].title = popups[i].title + " [Opens in pop-up window]";
    }
}
  }

  addEvent(window, 'load', findPopUps, false);
函数addEvent(elm,evType,fn,useCapture){if(elm.addEventListener){elm.addEventListener(evType,fn,useCapture);返回true;}否则if(elm.attachEvent){var r=elm.attachEvent('on'+evType,fn);返回r;}否则{elm['on'+evType]=fn;}
var newWindow=null;
函数closeWin(){
if(newWindow!=null){
如果(!newWindow.closed)
newWindow.close();
}
}
函数popuwin(url、类型、strWidth、strHeight){
closeWin();
type=type.toLowerCase();
如果(类型==“全屏”){
strWidth=screen.availWidth;
strHeight=screen.availHeight;
}
var工具=”;
如果(type==“standard”)tools=“可调整大小,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width=“+strWidth+”,height=“+strHeight+”,top=0,left=0”;
如果(type==“console”|| type==“fullscreen”)tools=“可调整大小,工具栏=no,位置=no,滚动条=no,width=“+strWidth+”,height=“+strHeight+”,left=0,top=0”;
newWindow=window.open(url,'newWin',tools);
newWindow.focus();
}
函数doPopUp(e)
{
//设置默认值-如果rel attrib中没有任何内容,则将使用这些默认值
var t=“标准”;
var w=“780”;
var h=“580”;
//寻找参数
attribs=this.rel.split(“”);
如果(attribs[1]!=null){t=attribs[1];}
如果(attribs[2]!=null){w=attribs[2];}
如果(attribs[3]!=null){h=attribs[3];}
//调用弹出脚本
popUpWin(this.href,t,w,h);
//如果弹出窗口激活,取消默认链接操作
if(window.event)
{
window.event.returnValue=false;
window.event.cancelBubble=true;
} 
若否(e)
{
e、 停止传播();
e、 预防默认值();
}
}
函数findPopUps()
{
var popups=document.getElementsByTagName(“a”);

对于(i=0;它将被每个弹出窗口拦截器清除。除非响应用户触发的事件,否则不要使用window.open。
function addEvent(elm, evType, fn, useCapture){if(elm.addEventListener){elm.addEventListener(evType, fn, useCapture);return true;}else if (elm.attachEvent){var r = elm.attachEvent('on' + evType, fn);return r;}else{elm['on' + evType] = fn;}}


var newWindow = null;

function closeWin(){
if (newWindow != null){
    if(!newWindow.closed)
        newWindow.close();
}
}

function popUpWin(url, type, strWidth, strHeight){

closeWin();

type = type.toLowerCase();

if (type == "fullscreen"){
    strWidth = screen.availWidth;
    strHeight = screen.availHeight;
}
var tools="";
if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
newWindow = window.open(url, 'newWin', tools);
newWindow.focus();
}

function doPopUp(e)
{
 //set defaults - if nothing in rel attrib, these will be used
var t = "standard";
  var w = "780";
 var h = "580";
 //look for parameters
  attribs = this.rel.split(" ");
 if (attribs[1]!=null) {t = attribs[1];}
  if (attribs[2]!=null) {w = attribs[2];}
  if (attribs[3]!=null) {h = attribs[3];}
  //call the popup script
  popUpWin(this.href,t,w,h);
  //cancel the default link action if pop-up activated
  if (window.event) 
    {
window.event.returnValue = false;
window.event.cancelBubble = true;
} 
  else if (e) 
{
e.stopPropagation();
e.preventDefault();
}
  }

  function findPopUps()
   {
   var popups = document.getElementsByTagName("a");
   for (i=0;i<popups.length;i++)
{
if (popups[i].rel.indexOf("popup")!=-1)
    {
    // attach popup behaviour
    popups[i].onclick = doPopUp;
    // add popup indicator
    if (popups[i].rel.indexOf("noicon")==-1)
        {
        popups[i].style.backgroundImage = "url(pop-up.gif)";
        popups[i].style.backgroundPosition = "0 center";
        popups[i].style.backgroundRepeat = "no-repeat";
        popups[i].style.paddingLeft = "3px";
        }
    // add info to title attribute to alert fact that it's a pop-up window
    popups[i].title = popups[i].title + " [Opens in pop-up window]";
    }
}
  }

  addEvent(window, 'load', findPopUps, false);