function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eric DelgadoEric Delgado 

Can I have Live Agent chat window in an iframe instead of popup window?

Hi,
I am able to integrate the live agent into my app, but it always pop up a new window. I am trying to make it display in an iframe within the page to avoid a pop up window. I have look into liveagent.startChatWithWindow(), but I couldn't get it to work when I pass the iframe id as parameter to the function. Is it possible to do that? Thanks!
Best Answer chosen by Eric Delgado
Nikhil Sharma 17Nikhil Sharma 17
You have to just take an iframe and passed the name of the iframe to startchatwithwindow 


<iframe name="myiframe" style="height:300px;">
 Here we show the chat window.
</iframe>


<script type='text/javascript' src='https://c.la10.salesforceliveagent.com/content/g/js/36.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la10.salesforceliveagent.com/chat', '57228000000PBN5', '00D280000019WTn');
</script>
<a id="liveagent_button_online_57328000000PBP1" href="javascript://Chat" style="display: Block;" onclick="liveagent.startChatWithWindow('57328000000PBP1','myiframe')"> Online </a><div id="liveagent_button_offline_57328000000PBP1" style="display: block;"> Offline Chat Content</div><script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('57328000000PBP1', document.getElementById('liveagent_button_online_57328000000PBP1'));
liveagent.showWhenOffline('57328000000PBP1', document.getElementById('liveagent_button_offline_57328000000PBP1'));
});</script>

 

All Answers

Nikhil Sharma 17Nikhil Sharma 17
You have to just take an iframe and passed the name of the iframe to startchatwithwindow 


<iframe name="myiframe" style="height:300px;">
 Here we show the chat window.
</iframe>


<script type='text/javascript' src='https://c.la10.salesforceliveagent.com/content/g/js/36.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la10.salesforceliveagent.com/chat', '57228000000PBN5', '00D280000019WTn');
</script>
<a id="liveagent_button_online_57328000000PBP1" href="javascript://Chat" style="display: Block;" onclick="liveagent.startChatWithWindow('57328000000PBP1','myiframe')"> Online </a><div id="liveagent_button_offline_57328000000PBP1" style="display: block;"> Offline Chat Content</div><script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('57328000000PBP1', document.getElementById('liveagent_button_online_57328000000PBP1'));
liveagent.showWhenOffline('57328000000PBP1', document.getElementById('liveagent_button_offline_57328000000PBP1'));
});</script>

 
This was selected as the best answer
Nikhil Sharma 17Nikhil Sharma 17
Hi Eric,

Instead of iframe id pass the name. It will work definitely.
Eric DelgadoEric Delgado
awesome, it works! thanks!
pranab khatuapranab khatua
Hi All,

I am facing problem in Salesforce Live chat. I have integrate the above code and everything fine. Whenever I want to move the chat window from popup to iFrame then I am getting error.

The  error is below
 
Refused to display 'http://law.force.com/prechatvf?endpoint=https%3A%2F%2F22og0.la2w2.salesforc…n_id%3D573j0000000k9bs%26session_id%3Dfdd5e246-7c3e-451e-b302-7ab2e72a027f' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

My testing link is http://thecloudsolutions.in/projects/livechat/index.php

Please help

Thanks,

 
Mike SladeMike Slade
Any luck overcoming this?  I have the same issue with my visual force chat window.
Nikhil Sharma 17Nikhil Sharma 17

Hi Pranab,

Here is the Solution fopr your Problem.

https://community.tableau.com/message/446711
http://stackoverflow.com/questions/20498831/refused-to-display-in-a-frame-because-it-set-x-frame-options-to-sameorigin

just go through these urls and you will find the solution.

Nikhil Sharma 17Nikhil Sharma 17

Hi Mike,

you have the "Refused to display" error or chat window is open in new window ?

Please clear so i can give a better solution.

If any problem please mail me on "sharma.nikhil.f26@gmail.com"