locked
Loading Javascript code into a C++ application?

    Question

  • I know that I can load a C++ library into a Javascript/HTML application but can I do the opposite?  That is, can I write my application in C++/XAML and somehow call into Javascript code?  It sure doesn't seem so, as there is no project template available under Javascript > Windows Metro style that lets me create a library, but I wanted to check anyway.
    Thursday, July 12, 2012 2:43 PM

Answers

  • You could load js into WebView and execute it. Use script notify callback to communicate back to c++ side. THis is the only way I could think of other then embedding js script engine into your app (spider monkey for example)
    Sunday, July 15, 2012 8:36 PM

All replies

  • Hi,

    You cannot use JavaScript to create a WinRT library. You can use C++ or C# and call it in JavaScript.

    For more information, please check 

    http://social.msdn.microsoft.com/Forums/en-us/winappswithnativecode/thread/44a63651-133f-459a-b1a2-2532892f3e28

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Jesse Jiang Wednesday, July 18, 2012 2:59 AM
    • Unmarked as answer by Adam Gross Wednesday, July 18, 2012 12:52 PM
    Thursday, July 12, 2012 4:09 PM
  • I doubt that this is possible (yet). I think how C++ metro apps internally work is that the IE control is created for you and your app is basically also just creating DOM elements under the hood. So if that is the case, the underlying IE could of course load JS also. But thats just theory.
    Saturday, July 14, 2012 5:00 AM
  • You could load js into WebView and execute it. Use script notify callback to communicate back to c++ side. THis is the only way I could think of other then embedding js script engine into your app (spider monkey for example)
    Sunday, July 15, 2012 8:36 PM