Chrome and Firefox javascript operations incompatibility?
- Hi I have tested my application on Chrome and Firefox and as far as I can tell they don't support the instantiation of a messenger application through javascript, is it the browsers fault? no problems at all on Internet Explorer however Chrome goes for the worst and does not even let download application contact information or create application contacts and other issues
Answers
- Yes it works on chrome but on the sample tags are used however the same errors appear about unsafe javascript calling but somehow tags manage to display pictures and so on, maybe this will be solved only after you come with the Silverlight wrapers :)
- Marked As Answer bySiebe TolsmaMSFT, OwnerTuesday, November 10, 2009 6:00 PM
All Replies
- Can you elaborate a bit more about your scenario? Do you have a link to your site so that we can take a look?
Thanks,
Lin - Hello I cannot show you the link because of the confidentiality agreement I have signed but here are my javascript functions that I believe are causing conflict some of them I call using javascript bridge and some of them are using scriptable methods
function onScriptsLoaded() { var token = document.getElementById("verifier").getAttribute("value"); var url = document.getElementById("channel").getAttribute("value"); app = Microsoft.Live.Messenger.Applications.Application.getApplication(token, url); app.get_contacts().add_addContactsCompleted(applicationContactEventHandler); app.get_contacts().add_removeContactsCompleted(RemoveAll_applicationContactEventHandler); }<br /><br /><br /><br /><br />
function OnUserPresencePropertyChanged(sender, e) { var name = e.get_propertyName(); if (name == "DisplayName") { var SLPlugin = document.getElementById("SLPlugin"); SLPlugin.Content.SL_DEFAULTVIEW.SetScriptableUser(messengerUser.get_presence().get_displayName()); SLPlugin.Content.SL_DEFAULTVIEW.SetScriptableCID(messengerUser.get_identity().get_cid()); messengerUser.set_applicationName("Funnel Web"); messengerUser.get_applicationContacts().add_addContactsCompleted(applicationContactEventHandler); messengerUser.get_applicationContacts().add_removeContactsCompleted(RemoveAll_applicationContactEventHandler); } if (name == "DisplayPictureUrl") { var SLPlugin = document.getElementById("SLPlugin"); SLPlugin.Content.SL_DEFAULTVIEW.SetScriptableImage(messengerUser.get_presence().get_displayPictureUrl().toString()); } }
function DeleteAllContacts() { var array = new Array(); if (IsMessengerUserSignedIn()) { if (messengerUser.get_applicationContacts().get_count() != 0) { for (var i = 0; i < messengerUser.get_applicationContacts().get_count(); i++) { array.push(messengerUser.get_applicationContacts().get_item(i).get_cid()); } messengerUser.get_applicationContacts().removeContactsByCid(array); } else { var SLPlugin = document.getElementById("SLPlugin"); SLPlugin.Content.SL_MATCHRESULTS.DoneRemovingContacts(); } } else { if (app.get_contacts().get_count() != 0) { for (var i = 0; i < app.get_contacts().get_count(); i++) { array.push(app.get_contacts().get_item(i).get_cid()); } app.get_contacts().removeContactsByCid(array); } else { var SLPlugin = document.getElementById("SLPlugin"); SLPlugin.Content.SL_MATCHRESULTS.DoneRemovingContacts(); } } }
function AddUserToAppContactList(cid) { var cids = new Array(cid); if (IsMessengerUserSignedIn()) { messengerUser.get_applicationContacts().addContactsByCid(cids, cids[0]); } else { app.get_contacts().addContactsByCid(cids, cids[0]); } }
I get errors when adding contacts or trying to delete them when using chrome signed or not signed in I belive the problems are not present on Firefox while I'm signed in I mean adding application contacts to user is not causing trouble but when adding to an instance of the application there are problems, as far as I know there should not be an issue with adding contacts when using user isntance or application instance, but maybe I'm doing in a way not supported by some browsers
thanks! Not sure exactly what caused the problem in your case. What error did you see? Can you try always use User instance to add application contacts whenever User instance is available instead of only when the user is signed in? Application was created to be used when there isn't a user associated, but you still want to show some other people's information. The functionality for Application is limited.
One additional thing I noticed, you are using a non-secured way to add application contacts (app.get_contacts().addContactsByCid(...), did you update your messenger application settings via the settings page (http://consent.messenger.services.live.com/applicationsettings.aspx?appid={appid}) ? You need to turn on "Do not use Messenger Application Key" in order to make addContactsByCid(...) fully functional.
Thanks,
LinHi I get this error on chrome
Value does not fall within the expected range.at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
at MS.Internal.XcpImports.MouseEventArgs_GetPosition(MouseEventArgs args, UIElement relativeTo)
at System.Windows.Input.MouseEventArgs.GetPosition(UIElement relativeTo)
at System.Windows.Controls.LinkLabel.OnMouseEnter(MouseEventArgs e)
at System.Windows.Controls.Control.OnMouseEnter(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
And yes I changed the application settings no problems adding contacts by CID
About check if the user instance is available you mean checking the user is not null? if it results null what should I do?
And the way I instantiate Application is the correct way?
thanksIt seems the error came from Silverlight. I am not sure how it is related to adding contacts via Application instance. Could you try pinpoint which line of code could cause this to happen by commenting out some code? You may want to look at Silverlight forum as well. I saw the following links, could it be related to your case?
http://forums.silverlight.net/forums/p/65225/160371.aspx#160371
The way you get Application instance is correct. However, Application type is used to support Messenger tags for the scenarios where the User has not been involved, e.g. show a contact's display name or display picture. If you use Messenger tags, Application or User instance are created automatically and the transition from Application mode to User mode is handled automatically. However, if, instead of using Messenger tags, you instantiate User class yourself, you need to pass in the Application instance as second parameter so that contacts added to Application instance can be transfered to the User instance.
Thanks,
Lin- Edited byLin Wang - MSFTOwnerFriday, October 16, 2009 6:27 AM
- Thanks Lin
I will check it out and pinpoint the exact line of code causing trouble but I think is related to application instance or operations on it, regarding the instantiation, yes I use messenger tags but only the app and bar tag so the Application and User instances are created automatically right? however how can I get the Application instance reference in javascropt? it lives only in the app tag isn't it? and I think I cannot get a reference to this Application instance so would you recommend to remove the app tag and do it like on msdn documentation "manually"? so I only have a single Application instance, could I leave the bar tag where it is? - Currently using Messenger Web Toolkit without specifying msgr:app tag is not supported.
For the same application Id there will be only one Application instance. The way you use to get Application instance is correct. However, you need to be aware, the way msgr:app tags works is that, it checks whether there is a need to create Application instance, if there is consent token available, Application instance is not really used.
Alternatively, I would recommend you to use contact related tags to specify the site contacts
- <msgr:app-contact> tag(non-UI). E.g. <msgr:app-contact cid="1234" >
- some UI tags containing cid value on your page, e.g. <msgr:display-name> <msgr:personal-message> <msgr:display-picture> <msgr:profile> etc., will be collected as application contacts.
If you want to create tag programmatically, you can use the createTag method.
E.g.
var element = Microsoft.Live.Messenger.UI.Tags.TagsFactory.createTag( 'app-contact', {'cid' : '1234' } );
document.body.appendChild(element);
In this way, you don't need to worry about User or Application.
Regards,
Lin - Thanks Lin
Ohh you are right the app-contact tag adds users to contact list, I don't remember if I tried that, but, so as you say if I create the app-tags then whichever way (user.get_applicationContacts() or Application.get_contacts()) will bring the same list of contacts added when using app-contact tag? also I was wondering that I don't really need to delete the contacts at any moment right? (I think that's the problem) just adding them through app-tag and findingByCid would not cause a noticeable overhead no matter how many users there are on app contacts?
I will try that so I quit dependance on manually adding or deleting contacts and that may solve the errors I hope - Hi I have replaced the adding contacts manually by using the app-tag now I don't see errors pop up con chrome, however as I finally managed to get to the so hidden javascript console window to see errors on page, why did they put such an important component there!, anyway I can see other errors that is about "security" on chrome I think, the "..." means my site and domain, no problems on IE so far, I'll check firefox, what is this about? note its a fresh chrome install
Unsafe JavaScript attempt to access frame with URL http://.../ from frame with URL http://settings.messenger.live.com/api/3.50.46010/Messenger.html?domain=...&env=wx.production.retail&signInServer=&scriptPath=&signInState=&localStorageDisabled=false&. Domains, protocols and ports must match.
www.wlmessenger.net/api/3.50.46010/retail/Microsoft.Live.Messenger.UI.Tags.js:40Uncaught Error: The tag 'app-contact' cannot have nested content. Make sure the tag is closed with a separate closing tag
Unsafe JavaScript attempt to access frame with URL http://.../ from frame with URL http://settings.messenger.live.com/api/3.50.46010/Reporting.html?p=uicontrols&prop1=Messenger%20External%20Platform&prop2=en-us&d=...&s=8+15. Domains, protocols and ports must match.Unsafe JavaScript attempt to access frame with URL http://.../ from frame with URL http://settings.messenger.live.com/api/3.50.46010/Reporting.html?p=uicontrols&prop1=Messenger%20External%20Platform&prop2=en-us&d=...&s=9. Domains, protocols and ports must match. - Ok I have checked Firefox and no error popups anymore but I can't see the application contact's display picture nor name, and no errors on the console neither it just does nothing, IE just runs my application flawlessly signed or not signed in the app-tag works and application contacts are there, but finally I can say what is failing, both chrome and firefox don't manage to get to the (ups, edited wrong handler) OnScriptsLoaded event handler having this script:
<script type="text/javascript" language="javascript"> var loader = Microsoft.Live.Core.Loader; // Use the loader to load custom scripts loader.addScript("jquery", "Scripts/JQuery.js"); loader.load(["jquery", "messenger.ui.styles.core", "messenger.ui"], onScriptsLoaded); </script><br/>
so something is wrong there, if the code does not reach the loaded event the app keeps being null and no handlers when adding contacts are reched that's what was happening from the begining, may I change this script? is not supported on chrome and firefox? :S- Edited byKeozII Saturday, October 17, 2009 3:22 AMwrong handler
- Oh it looks like I was lucky and got caught in the middle of the forums update lol and could not edit the last post strange behaviour, but nice upgrade by the way! :), anyway to the last script I quit the onScriptsLoaded and added the default styles loader
Microsoft.Live.Core.Loader.load(['Messenger.UI.Styles.Core', 'Messenger.UI'], null);
and had the handler on the loaded event where I finally instantiate my app on chrome and firefox! but guess what on chrome I still cannot get the applications contact's information!, the same errors about domain and ports! but finally I got it working flawlessly on firefox, no errors and got the display name and picture for app contacts, so one less problem at last! but why on earth chrome is so restrictive? shall we stop using chrome for the good of humanity? :) lol
edit: I notice that theapp.get_contacts().add_addContactsCompleted(applicationContactEventHandler);
method is not working on chrome, the handler is not attached to the event and then never reached and that is where my application magic starts :( so no magic what could be causing this on chrome to not able to catch the add contact event? these are the errors show on console
Unsafe JavaScript attempt to access frame with URL http://.../ from frame with URL http://settings.messenger.live.com/api/3.50.46010/Messenger.html?domain=...&env=wx.production.retail&signInServer=&scriptPath=&signInState=&localStorageDisabled=false&. Domains, protocols and ports must match.Unsafe JavaScript attempt to access frame with URL http://.../ from frame with URL http://settings.messenger.live.com/api/3.50.46010/Reporting.html?p=uicontrols&prop1=Messenger%20External%20Platform&prop2=en-us&d=...&s=8+9. Domains, protocols and ports must match.- Edited byKeozII Saturday, October 17, 2009 3:47 AMgot the problem
- It looks like this is a very known issue on chrome with other applications and maybe on Safari but have not tested it there, anyway I think I will skip chrome now, what do you think?
I am not sure what triggers that error. Have you tried the sample code (http://messenger.mslivelabs.com/Samples.zip, MakeYourWebSocial)? that should work with Chrome.
- Yes it works on chrome but on the sample tags are used however the same errors appear about unsafe javascript calling but somehow tags manage to display pictures and so on, maybe this will be solved only after you come with the Silverlight wrapers :)
- Marked As Answer bySiebe TolsmaMSFT, OwnerTuesday, November 10, 2009 6:00 PM

