forked from norm2782/uhc-jscript
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I am trying to get this example to work:
Here is my source file:
module Hello where
import Language.UHC.JS.Prelude
import Language.UHC.JS.Assorted
import Language.UHC.JS.W3C.HTML5
--data Document
--foreign import js "document" document :: IO Document
--foreign import js "%1.write()" documentWrite :: Document -> JSString -> IO ()
--foreign import js alert :: JSString -> IO ()
--
--foreign import js "%1.getElementsByName()" documentGetElementsByName :: Document -> JSString -> IO (NodeList Node)
--
--data NodeList x
--
--foreign import js "%1.length" nodeListLength :: NodeList Node -> Int
--foreign import js "%1[%2]" nodeListItem :: NodeList Node -> Int -> IO Node
--
--data Node
--
--foreign import js "%1.innerHTML" elementInnerHTML :: Node -> JSString
--foreign import js "%1.tagName" elementTagName :: Node -> JSString
main = do d <- document
n <- documentGetElementById d (stringToJSString "myHeader")
alert $ jsStringToString $ elementTagName n
alert $ jsStringToString $ elementInnerHTML n
I compile using uhc --import-path=uhcjs/uhc-js/src --target=js -O,2 jsffi.hs.
Then, I add an element using echo "<div id='myHeader'>test</div>" >> jsffi.html and then I open jsffi.html. Nothing is alerted.
I tried the example without uhc-js, that did not work either. What could be the problem?
Metadata
Metadata
Assignees
Labels
No labels