I have index.html and page.html
index.html has an anchor to page.html
I would the backbutton press and ask to the user if he really want go back to index.html
This is my code:
index.html
<!DOCTYPE HTML>
<html>
<head>
<title>First App</title>
<script src="cordova-2.6.0.js"></script>
<script>
function onLoad(){
document.addEventListener("deviceready",onDeviceReady, true);
}
function onDeviceReady(){
navigator.notification.alert("PhoneGap is working!!");
}
</script>
</head>
<body onload="onLoad();">
<h1>Welcome to PhoneGap</h1>
<h2>Edit assets/www/index.html</h2>
Go to page
</body>
</html>
page.html
<!DOCTYPE HTML>
<html>
<head>
<title>First App</title>
<script src="cordova-2.6.0.js"></script>
<script>
function onLoad(){
document.addEventListener("deviceready",onDeviceReady, true);
document.addEventListener("backbutton", onBackKeyDown, false);
}
function onDeviceReady(){
navigator.notification.alert("PhoneGap is working!!");
}
function onBackKeyDown(e) {
navigator.notification.alert("PhoneGap back is working!!");
}
</script>
</head>
<body onload="onLoad();">
<h1>Welcome to PhoneGap Page</h1>
<h2>Edit assets/www/page.html</h2>
</body>
</html>
The problem is that the back button press is not handled, but cordova is loaded correctly because I have the alert box showed.
What I am doing wrong?
I have a Samsung Google Nexus with Android 4.2.2
Thanks a lot.
Put your back button listener inside of the onDeviceReady function.
Related
I am trying to use React to render my UI in Play framework, but it doesn`t work. The same code just saved as .html file and opened directly can works normally, but if I place it in my play framework project as path: ./app/views/hello.scala.html, it just show title normally but nothing shown on my page. Here is my code:
<!DOCTYPE html>
<html>
<head>
<script src="./react/react.js"></script>
<script src="./react/react-dom.js"></script>
<script src="./react/browser.min.js"></script>
<title>React Title</title>
</head>
<body>
<div id="example"></div>
<script type="text/babel">
ReactDOM.render(
<h1>Hello, world!</h1>,
document.getElementById('example')
);
</script>
</body>
</html>
Please check weather all the js are loaded properly. check your assert path
<script src="assets/react/react.js"></script>
<script src="assets/react/react-dom.js"></script>
<script src="assets/react/browser.min.js"></script>
my question is how to get the contents of a textbox in my javahttpserver webinterface
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Message - Send</title>
</head>
<body>
<input id="message" type="text"/>
<button id="message_send" type="button">Send</button>
</body>
</html>
Do I need to do it via javascript or java?
Call this function with jquery in it when the button is pushed. (I put an alert function in it so you can test it)
Make sure you include the jquery.js
function getstuff(){
var box = $("#textboxtarget").val();
alert(box);
}
I have an applet within a browser which has a popup menu but when the menu is triggered it is shown away from the applet.
Here is the demo code
<html>
<head>
<title>Test the Applet</title>
</head>
<body>
<script type="text/javascript" src="http://java.com/js/deployJava.js"></script>
<script type="text/javascript">
var attributes= { code:'AppletPopupTest.AppletPopupTest', archive:'AppletPopupTest.jar', width:300, height:300 };
deployJava.runApplet( attributes, null, '1.6' );
</script>
</body>
</html>
This issue only happens on Mac 10.8 using firefox 21.0. Safari works fine.
I followed the trick for passing data to HTML webview from SO post How to pass parameter into HTML file from android.
I have this in my Java:
try {
String template = streamToString(getAssets().open("html/index.html"));
String data = template.replaceAll("%PARAMETER%", PARAMETER);
webView.loadDataWithBaseURL("file:///android_asset/html/", data, "text/html", "utf-8", null);
} catch (IOException e) {
e.printStackTrace();
}
In my HTML, I have the string "%PARAMETER%".
The solution works for my test device running Android 2.3.6, but didn't work in device running Android 4.1.1. The HTML have some CSS and JS files. Is the problem related to the content of the HTML page?
Any better approach on what I'm trying to achieve? Simple I just want to send data from Java to HTML webview.
This is the content of HTML:
<!DOCTYPE html>
<html>
<head>
<title>Like a Pub</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="jquery.mobile-1.2.0.min.css" />
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.mobile-1.2.0.min.js"></script>
<script type="text/javascript">
$('#index-page').live('pageshow', function(event, data){
//
});
</script>
</head>
<body>
<div data-role="page" id="index-page">
%WEBSITE_URL%
</div>
</body>
</html>
I'm looking to create an online form that on the surface is very basic.
The goal is to create a mailto form with submit button that, upon submission with copy the current url with in the browser address bar and paste it into the mailto email window.
The form itself is straight forward:
form method="post" action="mailto:address#address.ca">
Report a broken link, please use the submit button below. The URL for the broken link will be included automatically.
<br />
<input type="submit" value="Submit">
</form
the simpler the better, html/java is preferred... suggestions?
I suggest you get the URL with javascript's document.URL and do whatever you want to do with it.
Try this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'>
</script>
<script type='text/javascript'>
//<![CDATA[
$(window).load(function(){
var url = "mailto:address#address.ca?Subject=" + window.location;
$('#mailtoLink').attr('href', url);
window.alert($('#mailtoLink').attr('href')); // = url;
});//]]>
</script>
</head>
<body>
Some Text <a id="mailtoLink" href="mailto:address#address.ca" name="mailtoLink">Send Mail</a>
</body>
</html>