Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Eroor in browser Chrome on SendMessage method

Discussion in 'Editor & General Support' started by FoxUmkov, Nov 9, 2010.

  1. FoxUmkov

    FoxUmkov

    Joined:
    Aug 31, 2009
    Posts:
    39
    Write this error, then do "SendMessage" to Unity:
    "Uncaught TypeError: Object #<an HTMLObjectElement> has no method 'SendMessage'"
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you likely used the wrong thing to call it on then.
     
  3. perlohmann

    perlohmann

    Joined:
    Feb 12, 2009
    Posts:
    221
    Not nessesarily. I just created a post because I have a chrome issue aswell. We also use the SendMessage and this as it seems might be our problem. It worked yesterday, but not today. We have not updated the player between incidents.

    (my topic Chrome-issue)

    Edit: We use "Application.ExternalEval(...)" to get parameters from the url.
     
    Last edited: Nov 9, 2010
  4. FoxUmkov

    FoxUmkov

    Joined:
    Aug 31, 2009
    Posts:
    39
    in Unity WebPlayerPage Code change:
    in this:
    function GetUnity () {
    if (navigator.appVersion.indexOf("MSIE") != -1 navigator.appVersion.toLowerCase().indexOf("win") != -1)
    return document.getElementById("UnityObject");
    else if (navigator.appVersion.toLowerCase().indexOf("chrome") != -1)
    return document.getElementById("UnityEmbed");

    else if (navigator.appVersion.toLowerCase().indexOf("safari") != -1)
    return document.getElementById("UnityObject");
    else
    return document.getElementById("UnityEmbed");
    }
    add
    else if (navigator.appVersion.toLowerCase().indexOf("chrome") != -1)
    return document.getElementById("UnityEmbed");
     
    Last edited: Nov 9, 2010
  5. perlohmann

    perlohmann

    Joined:
    Feb 12, 2009
    Posts:
    221
    should the space character be there in the "chrom e" (and in the "safar i")?

    EDIT: a quick test say no =) but I cant see how that should fix it as that case should be cought by the else case. Going to try it out though.
     
    Last edited: Nov 9, 2010
  6. FoxUmkov

    FoxUmkov

    Joined:
    Aug 31, 2009
    Posts:
    39
    it's a forum bug.
     
  7. perlohmann

    perlohmann

    Joined:
    Feb 12, 2009
    Posts:
    221
    k =) well I can confirm that this fixes the problem if anybody else has the same problem.
     
  8. KDeriemaeker

    KDeriemaeker

    Joined:
    Nov 12, 2010
    Posts:
    17
    We are having the same issue. The GetUnity() solution FoxUmkov posted doesn't seem to fix the problem for us, though.

    FoxUmkov, how did you come upon this solution, and is there a reasoning behind it? I also don't quite understand how that could fix it, as the else block should return UnityEmbed anyway if it's not IE or Safari...
     
  9. KDeriemaeker

    KDeriemaeker

    Joined:
    Nov 12, 2010
    Posts:
    17
    Aha, found it. I was putting the chrome check AFTER the safari check - if I put it before the safari one, like in the example posted, it does work :) Apparently Chrome's application version string also contains "safari". Very annoying.

    Thanks FoxUmkov!
     
  10. cozza13

    cozza13

    Joined:
    Dec 13, 2010
    Posts:
    64
    Hi i am still having an issue with chrome, even using the above fix. Does any one have any other suggestions?
     
  11. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Welcome to the forum, Cozza13!

    Are you getting the same basic problem? Are there any error messages or other details you can give to narrow it down?
     
  12. Jimmy-Bekhuis

    Jimmy-Bekhuis

    Joined:
    Jan 31, 2011
    Posts:
    131
    I'm having issues with chrome 2, when using the first person character controller.
    If you move the mouse cursor outside of unity's webplayer you have no control anymore, so i can't turn around as intended.
    I fixed it with another script within unity but is requires the user to click on the webplayer first, not really what i wanted...
     
  13. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Reported that problem some time ago about the control disabling itself for the mouse if the mouse leaves the rect, while it works fine on IE etc
     
  14. cozza13

    cozza13

    Joined:
    Dec 13, 2010
    Posts:
    64
    I am having this issue and I have changed my code to ensure that Chrome picks it up:

    function GetUnity () {
    return document.getElementById("UnityEmbed");
    // return unityObject.getObjectById("UnityContent");
    //if (navigator.appVersion.indexOf("MSIE") != -1 navigator.appVersion.toLowerCase().indexOf("win") != -1)
    //return document.getElementById("UnityObject");
    //else if (navigator.appVersion.toLowerCase().indexOf("chrome") != -1)
    //return document.getElementById("UnityEmbed");
    //else if (navigator.appVersion.toLowerCase().indexOf("safari") != -1)
    //return document.getElementById("UnityObject");
    //else
    //return document.getElementById("UnityEmbed");
    }

    yet chrome does not see sendmessage
     
  15. cozza13

    cozza13

    Joined:
    Dec 13, 2010
    Posts:
    64
    I have solved it on my end:

    The steps i did to solve it.

    I rebuilt the game and started with the html output that is the default. Then replaced the pieces to use the html that I had added making sure that where Getunity and the .unity3d elements were in the default html remained in the same order. Then I just replace the output that unity creates for getunity() with the one several people have recommended and it all worked.

    function GetUnity () {
    if (navigator.appVersion.indexOf("MSIE") != -1 navigator.appVersion.toLowerCase().indexOf("win") != -1)
    return document.getElementById("UnityObject");
    else if (navigator.appVersion.toLowerCase().indexOf("chrom e") != -1)
    return document.getElementById("UnityEmbed");
    else if (navigator.appVersion.toLowerCase().indexOf("safar i") != -1)
    return document.getElementById("UnityObject");
    else
    return document.getElementById("UnityEmbed");
    }
     
  16. hutao

    hutao

    Joined:
    Jun 9, 2011
    Posts:
    8
    i have the same problem,how could i solve it