Вызов функции из файла UnityModule
Есть сайт на котором подключается скрипт в виде ссылки
<script src="blob:https://***/***" id="1"></script> В нем подключается несколько модулей с функциями через UnityModule. Один из из них Module["SetFullscreen"], вроде как делает полный экран, аналог f12 в браузере var UnityModule = (function() { var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; return (function(UnityModule) { UnityModule = UnityModule || {}; var Module = typeof UnityModule !== "undefined" ? UnityModule : {}; Module["SetFullscreen"] = (function(fullscreen) { if (typeof runtimeInitialized === "undefined" || !runtimeInitialized) { console.log("aaa") } else if (typeof JSEvents === "undefined") { console.log("bbb") } else { var tmp = JSEvents.canPerformEventHandlerRequests; JSEvents.canPerformEventHandlerRequests = (function() { return 1 } ); Module.ccall("SetFullscreen", null, ["number"], [fullscreen]); JSEvents.canPerformEventHandlerRequests = tmp } } ); return UnityModule; } ); })(); Как можно через javascript вызвать этот модуль/функцию в консоли? |
I'm not sure exactly what your problem is, but you can try the following:
<html> <head> <script type = "text/javascript"> functionmyfunction() { alert("how are you"); } </script> </head> <body> <p>Click the following button to see the function in action</p> <input type = "button" onclick = "myfunction()" value = "Display"> </body> </html> It will be create and define a function in the HTML document's head section. To invoke this function in the html document, I have to create a simple button and using the onclick event attribute (which is an event handler) along with it,I can call the function by clicking on the button driving directions. |
fizzparent,
Пожалуйста, отформатируйте свой код! Для этого его можно заключить в специальные теги: js/css/html и т.п., например: [html run] ... минимальный код страницы с вашей проблемой [/html] О том, как вставить в сообщение исполняемый javascript и html-код, а также о дополнительных возможностях форматирования - читайте http://javascript.ru/formatting. |
Часовой пояс GMT +3, время: 11:34. |