Invoking Applet Methods - Firefox 12 bug - java

I have one problem with Firefox 12 (newer Firefox works well, and another browsers works well too).
In Firefox 12 MyApplet is undefined.
In another browsers everything works well.
In newer Firefox everything works well too.
but I need to fix this in firefox 12 too.
....
....
<html>
<head>
<script type="text/javascript">
function callbackFunction() {
....
MyApplet.getData();
// My applet is undefined in firefox 12.
....
}
</script>
</head>
<body >
<script src="https://www.java.com/js/deployJava.js"></script>
<script >
var javaVersion='1.6';
var startApplet = function(){
var attributes = {
id: 'MyApplet', scriptable: 'true',
code:'X.Y.Z.MyApplet.class',
archive:'<%=request.getContextPath()%>/applets/MyApplet.jar'
};
var parameters = {
challenge : "${serverChallenge}",
callbackFunction : 'callbackFunction()',
language: "${pageContext.response.locale.language}"
};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
}
startApplet();
</script>
</body>
</html>
is it possible, to solve that problem using JS or something like that?

that's solution: updating Firefox;

Related

javascript function not getting executed

I want to execute a javascript function in an external js file when the page is loaded. This is the code in the jsp file where the function is called from, I placed it at the bottom of the jsp
<%-- Begins countdown --%>
<script src="/pub/scripts/counter.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload=startCountdown;
</script>
this is the function in the js file
function startCountdown() {
var TIMEOUT = 900000;
var COUNT_BACK = 3;
setTimeout("displayWarning("+COUNT_BACK+")", TIMEOUT);
}
when the page loads in the browser I see that the script is loaded but the startCountdown function never gets executed. How can I make this work?
I would use <body onload="startCountdown()"> in your html to ensure that the page must load completely before executing the script.
Change window.onload=startCountdown; to window.onload=startCountdown(); and use defer
<%-- Begins countdown --%>
<script defer src="/pub/scripts/counter.js" type="text/javascript"></script>
<script defer type="text/javascript">
window.onload=startCountdown();
</script>
this is the function in the js file
var startCountdown = function() {
var TIMEOUT = 900000;
var COUNT_BACK = 3;
setTimeout("displayWarning("+COUNT_BACK+")", TIMEOUT);
};

getting an immediate redirect. Why is this so?

I am trying to redirect the user from one jsp page to another jsp page after making him wait for 10 seconds or 10000 milliseconds. But there is a redirect as soon as the page is opened in the browser. Why is this is so ? Is there anything wrong in the following code ? I am calling the redirectFunction which does the redirect.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP - 1</title>
<script>
function redirectFunction() {
<% response.sendRedirect("jsp-2.jsp"); %>
}
</script>
</head>
<body>
<h1>
Wait while you are redirected...
</h1>
<script type="text/javascript">
setTimeout(redirectFunc,10000); // wait for 10 seconds,then call redirectFunc
</script>
</body>
You sends redirect exactly from server that`s why it fired immediatelly.
If you want to fire redirect after 10 seconds than you need to change your code:
function redirectFunction() {
window.location.href = "jsp-2.jsp"
}
and setTimeout(redirectFunction,10000);
Actually when you call <% response.sendRedirect("jsp-2.jsp"); %> Java server sets http code 302 to your http response, and header Location: jsp-2.jsp
And browser redirects to page specified in Location header immediately.
Hope it helps.
the code in scriptlet is executed on the server, it is not javascript. use this
function redirectFunction() {
window.location.href = "jsp-2.jsp";
}
Assuming you're using HttpServletResponse, what's happening is that you're sending the HTTP location header with a status code 302. This happens when the page is requested, not during client-side execution of the JavaScript.
If you want it to be during JavaScript execution you need to assign the URL you want to window.location.
window.location = "http://google.com";
for example
This is because
<script>
function redirectFunction() {
<% response.sendRedirect("jsp-2.jsp"); %>
}
</script>
is translated and executed as
out.print(" <script> function redirectFunction() {");
response.sendRedirect("jsp-2.jsp");
out.print("</script>");
The call sendRedirect is executed on the server side, while preparing your page, and it's performing the redirect. You can do the sleep and the redirect in javascript only, using window.location.

Jquery Autocomplete token input does'nt work in safari and chrome

Autocomplete token input box works properly in IE and Firefox but it doesn't work in safari and crome.
this is a part of code
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.4.min.js"></script>
//for auto complete
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jqueryAutocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jqueryAutocomplete/jquery.ajaxQueue.js"></script>
<link type="text/css" media="screen" rel="stylesheet" href="<%=request.getContextPath()%>/css/jqueryAutocomplete/jquery.autocomplete.css" />
$j(document).ready(function(){
$j("#id_CBRERegion").tokenInput(path + "fetchAutoCompleteResult.do?method=regionList", {
theme: "facebook",
queryParam: "search",
minChars: 1,
preventDuplicates: true,
hintText:"CBRE Region",
prePopulate: selRegCode
});
$j('#id_CBRERegion').prev().find("input").blur();
registerAutoEvent('id_CBRERegion','id_CBRERegion_Temp');
if(document.getElementById('id_CBRERegion').value != "") {
$j('#id_CBRERegion_Temp').hide();
} else if(document.getElementById('id_CBRERegion').value == "") {
$j('#id_CBRERegion_Temp').next().hide();
}
});
Please suggest..
I just visited http://jqueryui.com/demos/autocomplete/ in Chrome and Safari and it works.
Many factors could be causing the problem, from css to data.
Best way to resolve and learn the function.
start from a simple example off the site
Add in your bits slowly until you see it fail.

Problem with jquery and IE 8 and later

In Firefox work, but when load page in IE8 i get only blank page and source HTML-code available.
I delete
<script src="/NewsManager/js/jquery.js"
type = "text/javascript"
</script>
and all work without script.
NetBeans 6.7, ApacheTomcat, JSP
You missed the closing > in second line:
<script src="/NewsManager/js/jquery.js"
type = "text/javascript"> <!-- close the opening script tag HERE -->
Try this:
<script src="/NewsManager/js/jquery.js" type="text/javascript"></script>

instantiate an object within javascript

**<%# page import="com.ampliflex.commons.Ampliflex" %>**
<html>
<head>
<title>Search Result </title>
<style>
img{ height: 150px; float: left; border: 3;}
div{font-size:10pt; margin-right:150px;
margin-left:150px; }
</style>
<script type="text/javascript" src="jquery-1.6.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
**Ampliflex ms = Ampliflex.getInstance();
String mailHost = ms.getMailServer();**
// This function get the search results from Solr server
$("#submit").click(function(){
var query=getquerystring() ; //get the query string entered by user
Here in this, I imported a java class and instantiate its object. but object is not visible and script is generating an error "missing ; before statement
Ampliflex ms = Ampliflex.getInstance(); "...i am not getting why so.
EDIT:
The problem is i need to access this mailHost with in javascript. if i instantiate object with in <%.. %> then mailHost is local variable and am not able to access in javascript tag. is there any solution for it.
You are trying to instantiate java object but, without a scriptlet
it should be some thing like
<%
Ampliflex ms = Ampliflex.getInstance();
String mailHost = ms.getMailServer();
%>
$(document).ready(function(){
//Mail host
var mailHost='<%= mailHost %>';
// This function get the search results from Solr server
$("#submit").click(function(){
var query=getquerystring() ;
And, if you want to invoke method after page is loaded, try using ajax.
Problem here is this line:
Ampliflex ms = Ampliflex.getInstance();
String mailHost = ms.getMailServer();
This is actually Java code. This cannot execute on client side. Use scriptlet tags.

Categories