You need to sign in to do that
Don't have an account?
KiloJ
Popup Component on site page not showing
Hi there. I have created a site page that works fine. However I have a javascript popup that
appears after 7 seconds. It pops up but with the message - Authorization required.
I cannot seem to be able to fix this.
my vf page does not have any inputFields, nor does it use a controller of any kind.
It's just raw html/javascript/css.
I have added the page to the site and to the guest profile:
But what I get from my site page when the popup appears is:
Note: I have removed the URL from the screenshot.
Any ideas?
Many thanks
the pop-up code uses a relative url from root "/apex/pagename" and doesn't include the path
you don't need to specify /apex/ but you need the site path. /mydemo/pagename
there are visualforce expressions {!$Page.pagename} or for the path {!$Site.Prefix} you can sue rather than hardcoding the path or the page name.
All Answers
can you post a snippet from this page? How is it included, what does it do?
You get this error when the page tries to access an information that is not granted or allowed for the site.
Also you can't call salesforce api from this javacript (like scontrol) because there is no session id for site access and api access from client via site is not allowed.
Hi Bulent. Thanks for the reply.
I'm not accessing the SF API at all.
Here's the code (which works perfectly if the VF page is invoked directly inside the org like .../apex/ChatBubble/)
<apex:page title="CMC Agent Help" sidebar="false" showHeader="false"> <style type="text/css"> .msgArea { background-color: #FFF; color:#444444; font-family:Tahoma,Arial,sans-serif; font-size:0.7em; font-weight:bold; line-height:1.3em; width: 367px; height: 150px; } .msgInput { color:#444444; font-family:Tahoma,Arial,sans-serif; font-size:0.7em; line-height:1.3em; width:367px; height:50px; margin-top:10px; } #agentName { width:367px; border-top: 2px solid #DCECF5; border-bottom: 2px solid #DCECF5; color:#444444; font-family:Arial; font-size:22px; line-height:1.3em; } .postButton { margin-top:10px; } </style> <script> function postMessage() { var currentTime = new Date(); var inputMsgArea = document.getElementById("chatArea"); var msg = document.getElementById("inputMessage"); var messageStr = "\r\n" + currentTime.getHours() + ":" + currentTime.getMinutes() + ":" + currentTime.getSeconds() + " - " + msg.value + "\r\n"; var txtNode = document.createTextNode(messageStr); inputMsgArea.value += messageStr; msg.value = ''; window.setTimeout('showGoodbyeMsg()',4000); } function showGoodbyeMsg() { var currentTime = new Date(); var inputMsgArea = document.getElementById("chatArea"); var goodbyeMsg = "\r\n" + currentTime.getHours() + ":" + currentTime.getMinutes() + ":" + currentTime.getSeconds() + " - No problem. If I can be of assitance, just ask!\r\n"; inputMsgArea.value += goodbyeMsg; } </script> <apex:form > <apex:outputPanel > <apex:image value="{!$Resource.CompanyLogo}" /> <div id="agentName"> <apex:outputLabel value="Agent Name: " for="agentNameField" style="color:#B3B3B3;" /> <apex:outputText value="Joe Bloggs" id="agentNameField" style="color: #6EA3B7" /><br/> </div> <br /> <textarea id="chatArea" readonly="readonly" class="msgArea" /><br /> <textarea id="inputMessage" class="msgInput" /><br /> <button type="button" onclick="postMessage();" class="postButton">Post</button> </apex:outputPanel> <script> window.onload = new function() { showInitMsg(); }; function showInitMsg() { var currentTime = new Date(); var agentWelMsg = currentTime.getHours() + ":" + currentTime.getMinutes() + ":" + currentTime.getSeconds() + " - Hi there. My name is Joe Bloggs. I see that you are interested in signing up to CMC Markets. Can I help you in any way?\r\n"; var inputMsgArea = document.getElementById("chatArea"); inputMsgArea.value = agentWelMsg; } </script> </apex:form> </apex:page>
you mentioned this is a pop-up page?
how is it called from the site page?
does your site has a path? (like abc.force.com/path/)
It's called from the main site home page like so:
function showChatPopup() { window.open("/apex/ChatBubble", "Agent Chat", "width=393,height=443,resizable=no"); }
Is this the problem?
Many thanks
Yes indeed - it's
http://mysite-1236fea2b59.force.com/mydemo
(changed url names - but path is mydemo)
Thanks
the pop-up code uses a relative url from root "/apex/pagename" and doesn't include the path
you don't need to specify /apex/ but you need the site path. /mydemo/pagename
there are visualforce expressions {!$Page.pagename} or for the path {!$Site.Prefix} you can sue rather than hardcoding the path or the page name.
Excellent. I'll give that go. Thank you very much Bulent.
Regards