Applet Jpopupmenu displays away from specified coordinates - java

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.

Related

Render React UI in play framework

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>

Pass Data from Android Java to Webview - jQueryMobile

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>

PhoneGap handle back button to not close the app

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.

date does not get printed : why is this so?

In the javascript function jsp I am trying to print the date.But it doesn't get printed. Why is this so ? The date should get printed before the text in the h1 tag. But the problem is date doesn't get printed ! Why is this so ?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP - 1</title>
<script>
function jsp() {
<%= new java.util.GregorianCalendar().getTime().toString() %>
}
</script>
</head>
<body>
<h1>
Was I printed first ? Or is it the date... ..
</h1>
<script type="text/javascript">
setTimeout(jsp,2000);
</script>
</body>
<script>
function jsp() {
document.write('<%= new java.util.GregorianCalendar().getTime().toString() %>');
// or any other JS function you may want to use
}
</script>
You're mixing server-side and client-side.
With your original function, your browser will see (for example)
<script>
function jsp() {
2012-08-24 11:57:00
}
</script>
but this isn't JS-valid (as you see).
And to answer your hidden question, the date will be printed last, because it's located after the h1 (in a DOM-speaking way).

Closing open XML tags with regex

Basically I want to do the same as here which is done in Python.
I'd like to replace all self-closed elements to the long syntax.
Example
<iframe src="http://example.com/thing"/>
becomes
<iframe src="http://example.com/thing"></iframe>
Full example:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/sample.css">
<title></title>
<script type="text/javascript" src="/swfobject.js">
//void
</script>
<script type="text/javascript" language="JavaScript" src="/generate.js">
//void
</script>
<script type="text/javascript" language="JavaScript" src="/prototype.js">
//void
</script>
</head>
<body id="mediaPlayer" style="margin:0;padding:0;">
<script type="text/javascript">
swfobject.registerObject('id_G12564763');
function getFlashObject() {
var object;
if (navigator.appName == 'Microsoft Internet Explorer' || navigator.userAgent.indexOf("Chrome")!=-1)
{
object = document.getElementById('id_G12564763');
}
else
{
object = document['flash_id_G12564763'];
}
return object;
}
</script>
</body>
</html>
This can be used to replace one tag (code in javascript).
var becomes = "<iframe src='http://example.com/thing'/>".replace(/<(\w*) (.*)\//,'<$1 $2></$1')
The same, in Java.
String becomes = "<iframe src=\"http://example.com/thing\"/>".replaceFirst("<(\\w*) (.*)\\/", "<$1 $2></$1");
Ok guys. I found a workaround. I hooked the output method to xml where this html comes from and the XSLT engine takes care of closing those open tags for me. Thanks for answers, but if you happen to have a solution for the problem pls, leave your answer and I will mark it as an answer. This could be useful for others.
String resultHtml = inputHtml.replaceAll("(?six)<(\\w+)([^<]*?)/>", "<$1$2></$1>");
and this will properly handle tags that are not terminated like <hr> and <img>

Categories