- Home /
Unity and Website Javascript
On my website, I can pull the Username of the signed in user by executing a javascript in the console( In Chrome) by typing
`javascript : document.getElementById("item-user").innerText)`
The problem is, I need this information INSIDE the WebPlayer during runtime. Is is possible using Application.ExternalCall; or Application.ExternalEval? I dont understand because I hear that Unity cannot execute javascript commands.
Snippit of my Script Right now
if(GUILayout.Button("Get My UserName", titleStyle)){
Application.ExternalCall("document.getElementById('item-user').innerText");
}
Answer by programmrzinc · Nov 16, 2012 at 11:45 PM
Inside the HTML( for the .unity3d file) I added:
function GetUserName(){
if(document.getElementById("fw-member-presence").firstChild.innerText != null){
var unity = GetUnity();
unity.SendMessage("WebPhone", "PickUp", document.getElementById("fw-member-presence").firstChild.innerText);
}
}
In the console I did
javascript : GetUserName()
This found my function that I created and got the return value. Use This manual to help you
NOTE: This works for a webs.com account ONLY
Your answer
![](https://koobas.hobune.stream/wayback/20220613084006im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Javascript How to Activate/Deactivate GameObject Arrays 1 Answer
I am having an issue with returning an array 2 Answers
whats wrong? nullpointer 1 Answer