PhoneGap "On menu press launch url" - java

I am currently working on an e-book for the android platform. I'm using Eclipse, Dreamweaver and the phonegap libraries. Is there a way i can have a new page or dialog display on the action of pressing the menu key.

Add this line to your onLoad handler
<script type="text/javascript" charset="utf-8">
function onLoad() {
document.addEventListener('menubutton', onMenuKeyDown);
}
function onMenuKeyDown() {
}
You can then perform any action you like in your onMenuKeyDown function.

Related

i need java code to open html code onclick event

I have banner HTML code if people goes to click on a text, the click should open my banner HTML page. I need a clickable text to open my HTML page. Below is my banner HTML page, i need clickable text for below banner HTML. so i need java code to open below html page on click event.
<script type="text/javascript" src="http://adhitzads.com/787096"></script>
HTML
<div id="div">TEXT</div>
javascript
$("#div").click(function () {
window.location.href="https://www.google.com";
});
and include any latest jquery...you can use
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>

Removing close button and back button

Can someone tell me how can I disable the browser's close button and back button. i.e user can not see the browser's close button or back button or can not click on the close button or back button of the browser. If user clicks nothing should happen or it should be completly hidden from user.
Solution can be in java or javascript or win32 apis..
We use this technique in-house for opening a browser window on top of all other apps so the user can use in-house hosted forms/webapps etc. Please remember to offer a close button.
NB: This only works for IE:
<html xmlns="http://www.w3.org/1999/xhtml">
<script for="window" event="onload">
window.open('main.jsp',
'Your Name',
'width=800,height=600,resizable=0,status=0,toolbar=0');
<!-- Stops user from being able to press BackSpace -->
window.opener = window.top;
window.open('', '_self', '');
window.close();
</script>
</html>

Android preferences from settings menu - for phonegap developer

I've never written any single line in Java and I doesn't know much about the Java world, so when I hear that I can create android apps using phonegap I was very happy. But as I discovered later, I cannot escape from Java if I want to do something more.
I want to create settings page for my application, I found phongeap extension that allows me to read the phonegap applications settings but to use it I must create the settings GUI which can be done via XML and some Java. I found good tutorial to do it but since I'm not Java developer I cannot understand much from it.
Can someone tell me where to put all this Java and XML stuff to simply get the settings GUI working in phonegap application. I mean what files I need, with what content and in what directories.
With phonegap you can escape all the java codes, as you'll see in the following code, you wont need any java code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Cordova Menu Button Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when Cordova is loaded.
// At this point, the document has loaded but cordova-2.3.0.js has not.
// When Cordova is loaded and talking with the native device,
// it will call the event `deviceready`.
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// Cordova is loaded and it is now safe to make calls Cordova methods
function onDeviceReady() {
// Register the event listener
document.addEventListener("menubutton", onMenuKeyDown, false);
}
// Handle the menu button
function onMenuKeyDown() { alert("menu btn pressed");
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>
Dont use plugins for this feature, just go to the main documentation.
Also you may find the other events like:
deviceready
pause
resume
online
offline
backbutton
batterycritical
batterylow
batterystatus
menubutton
searchbutton
startcallbutton
endcallbutton
volumedownbutton
volumeupbutton

"Save primefaces chart as" with export function

I use Primefaces 3.4 with Apache MyFaces 2.1.8 on WebSphere Application Srever 8.
I have some charts. Now I want to make it possible to save the chart as image.
With PF comes the export function for charts.
In PF showcase they export the image in a new dialog:
look here
I want to get the typical "save as" dialog when I push the button.
Can someone give me a hint how to write the javascript for this?
It's something like this:
<script type="text/javascript">
//
function exportChart() {
//export image
$('#chart').exportAsImage();
}
//
</script>
Best regards
I am late but hope it will help others to solve the problem.
Make sure that "chart" and "dlg" are javascript variable
<script type="text/javascript">
//
function exportChart() {
//export image
$('#output').empty().append(chart.exportAsImage());
//show the dialog
dlg.show();
}
//
</script>
The image exported is an image base 64. You can use next:
yourInputText.value = chart.exportAsImage().src;

JavaApplet when you press a button/ click on image

Is it possible to run JavaApplet when you press a button , or when you click on the image on the webpage?
Maybe you guys can share any example, related html/jscript/jquery?
What is wrong with my code at this point?
<html>
<script>
function openApplet(){
var attributes = {codebase:'.',
code:'d.Applet',
archive:'Applet.jar',
WIDTH=500, HEIGHT=300} ;
}
</script>
<body>
<applet id="myapplet"
CODEBASE="."
ARCHIVE="Applet.jar"
CODE="d.Applet"
WIDTH=500 HEIGHT=300
style="visibility:hidden;"
>
</applet>
<input value="Applet_on_Click" onclick="openApplet()" type="button">
</body>
</html>
I'm just looking for very simple solution. Click on the image , applet shows up, click on the different image , another applet will show up. Or maybe these things can happen when we press a button too?
Update
Thank you slowpoison for the information!
But I'm missing something.
There is my original code now:
http://www.text-upload.com/read.php?id=360320&c=7544773
This is working just with pure html. But there is no action when you click on the button.
If I disable this row "style="visibility:hidden" , applet will show up without a click.
I wan't to show applet just after the button click. :(
You should add the applet tag to the document in the onclick handler.
var applet = document.createElement("applet");
// fill in various attributes for applet
// ...
// "install" the applet
document.getElementById("appletContainer").appendChild(applet);

Categories