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
Alexander RochaAlexander Rocha 

Live Agent - Prechat error

Hi,

How are you all?
I'm trying to implement a prechat code in my page, and when I submit the form, I get an error like this "The chat window can only be opened with a button - can not access it directly."

Default code is being used (from live agent doc):

<apex:page showHeader="false">
    <!-- This script takes the endpoint URL parameter passed from the deployment
      page and makes it the action for the form -->
    <script type="text/javascript">
         (function() {
         function handlePageLoad() {
           var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
           document.getElementById('prechatForm').setAttribute('action',
           decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
         } if (window.addEventListener) {
                  window.addEventListener('load', handlePageLoad, false);
       } else { window.attachEvent('onload', handlePageLoad, false);
                  }})();
    </script>
    <h1>Pre-chat Form</h1>
    <form method='post' id='prechatForm'>
          First name: <input type='text' name='liveagent.prechat:FirstNameDetail'
            id='customField1' /><br />
          Last name: <input type='text' name='liveagent.prechat:LastNameDetail'
            id='customField2' /><br />
          Department: <select name="liveagent.prechat.buttons">
              <!-- Values are LiveChatButton IDs. -->
              <option value="573a00000000001">Customer Service</option>
              <option value="573a00000000002">Technical Support</option>
              <option value="573a00000000001,573a00000000002">Customer Service if online,
              otherwise Technical Support</option>
          </select><br />
    
          
    
          <input type='submit' value='Request Chat' id='prechat_submit'/>
    <style type="text/css">
    p {font-weight: bolder }
    </style>
    </form>
</apex:page>

 
ShashankShashank (Salesforce Developers) 
If you are using internet explorer, please ensure "protected mode" is turned off, as it is not recommended by salesforce.