-
-
Save pietromalerba/5267161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Titanium.UI.setBackgroundColor('#000'); | |
// Create a window | |
var win = Titanium.UI.createWindow({ | |
title:'Web Test', | |
backgroundColor:'#fff' | |
}); | |
// and now a webView | |
var webview1 = Titanium.UI.createWebView({url:'somePage.html'}); | |
// Attach an APP wide event listener | |
Ti.App.addEventListener('webToTi', function(e) { | |
Ti.API.info('webToTi Sent:'+e.test); | |
}); | |
// Add the webView to the window | |
win.add(webview1); | |
// Create a timeout - we want time for the window to be ready before we fire the event | |
setTimeout(function(e){ | |
Ti.App.fireEvent("webPageReady", {message:"bob"}); | |
},10000); // 10s should be enough :) | |
// Open the Window | |
win.open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
</head> | |
<body id="mybody" style="height:500px;background-color:#999"> | |
Hello from local webview. You should see an indicator in the middle and my text should be blue. | |
We are also including JQuery | |
<div id="foo" style="margin-top:20px;font-weight:bold">hello</div> | |
<script> | |
Ti.App.addEventListener('webPageReady',function(e) { | |
alert('The word is ' + e.message); | |
}); | |
</script> | |
<script> | |
var payload = {test:"fred"}; | |
Ti.App.fireEvent('webToTi', payload); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment