473,796 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Applet Works For Ie But Doesn't For Firefox

1 New Member
www.statehousenews.com/beta/scroller2.asp

Is a code I wrote that retrieves data from a txt file and displays it into a txt scroller. XMLhttpRequest( ) is used to open and retrieve the data. The javascript works fine in IE7 but doesn't work at all for Firefox/2.0.0.13.

Here's the code:

[HTML]<%@LANGUAGE="VB SCRIPT" CODEPAGE="65001 "%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitl ed Document</title>
</head>

<body>

<script type="text/javascript">
<!--Custumazible Java Applet-->
var line=new Array()

var txtFile = new XMLHttpRequest( );
txtFile.open("G ET", "http://www.statehousen ews.com/public/scroller2.txt", true);
txtFile.onready statechange = function()
{
if (txtFile.readyS tate === 4)
{ // Makes sure the document is ready to parse.
if (txtFile.status === 200)
{ // Makes sure it's found the file.
document.write( "Yes, we found the file");

allText = txtFile.respons eText;
document.write( allText)
linesFed = txtFile.respons eText.split("\n "); // Will separate each line into an array

}
document.write( linesFed[1]);


counter = 0;
for(var t = 1; t<=linesFed.len gth; t++)
{
line[t] = linesFed[counter];
counter = counter + 1;
}


}

}

txtFile.send(nu ll);


// Specify font size for scroller below **This is where my code txt scroller start.
var ts_fontsize="12 px"

var longestmessage= 1
for (i=2;i<line.len gth;i++){
if (line[i].length>line[longestmessage].length)
longestmessage= i
}

//Auto set scroller width
var tscroller_width =line[longestmessage].length



lines=line.leng th-1 //--Number of lines

//if IE
if (document.all|| document.getEle mentById){
document.write( '<form name="bannerfor m">')
document.write( '<input type="text" name="banner" size="'+tscroll er_width+'"')
document.write( ' style="backgrou nd:url(images/Layout_7.jpg) no-repeat; color: '+document.body .text+'; font-family: verdana; font-size: '+ts_fontsize+' ; font-weight:700; border:none" onfocus="blur() ">')
document.write( '</form>')
}

temp=""
nextchar=-1;
nextline=1;
cursor="|"
function animate(){
if (temp==line[nextline] & temp.length==li ne[nextline].length & nextline!=lines ){
nextline++;
nextchar=-1;
document.banner form.banner.val ue=temp;
temp="";
setTimeout("nex tstep()",2000)}
else if (nextline==line s & temp==line[nextline] & temp.length==li ne[nextline].length){
nextline=1;
nextchar=-1;
document.banner form.banner.val ue=temp;
temp="";
setTimeout("nex tstep()",2000)}
else{
nextstep()}}

function nextstep(){

if (cursor=="|"){
cursor=" "}
else if (cursor==" "){
cursor="|"}
else if (cursor=="|"){
cursor=" "}
else if (cursor==" "){
cursor="|"}

nextchar++;
temp+=line[nextline].charAt(nextcha r);
document.banner form.banner.val ue=temp+cursor
setTimeout("ani mate()",75)}

//if IE 4+ or NS6
if (document.all|| document.getEle mentById)
window.onload=a nimate
// -->
</script>
</body>
</html>[/HTML]
Apr 6 '08 #1
1 1377
acoder
16,027 Recognized Expert Moderator MVP
You have an error on line:
Expand|Select|Wrap|Line Numbers
  1. var tscroller_width=line[longestmessage].length
There are a few problems with the script. You're making an asynchronous request, but expecting the result immediately afterwards. You're also using document.write( ) after the page has loaded. Remove those since they're only for testing.

All the code relating to the line array should be when the response is ready in the onreadystatecha nge function, not outside it.
Apr 6 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1748
by: admin | last post by:
Hi all, I wrote a small text editor (using a JTextPane) in order to ease the use of a CMS, in a more WYSIWYG way. Basically, you can see directly the effect of setting the background color, the text color, bold/italic/underlined styles and so on... You can have several applet on one page as there is one applet per column and per language.
8
3394
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some problems. IE crashes when one refreshes the page or leave the page. This happens only after calling the Java method more than once. It does not crash if the Java method is called just once and then the page is refreshed. FireFox does not crash at all...
2
5430
by: Nick Wedd | last post by:
Here is a test page http://www.maproom.org/maps/historical/droysens/1886/testj.html which uses a Java applet to take a .DjVu format file and display the image which it encodes. The page is simple html, you can view its source. When I started using this applet, it worked on my system with Mozila/Netscape, Mozilla/Firebird, Mozilla/Firefox, and Internet Explorer, all running on my WindowsXP system. I was warned that the applet worked...
2
9520
by: Blondie21 | last post by:
Hi, I have a .jsp file in the following format: .... html headers, jsp code, html code... <jsp:plugin type="applet" code="path.in.packet.appletclassname.class" codebase=".." jreversion="1.5"
4
1482
by: Marc | last post by:
I am investigation how I should let an IntraNet application talk to a scanner on the client site. One possibility is using an active x component and IE and a library called twain. But I think I could also use a java version of that twain lib, and an applet. I cannot find much information about this, I am wondering if anyone in this group ever tried it. How should I go about. One problem on the intranet is that the users are also using...
3
4392
by: Jimbo | last post by:
I have a website & applet produced under Windows-XP. It works fine. I took it to a machine running Windows 98 & an earlier version of Java to test what happens when I open the web page using IE6 & FireFox. The html invoking the applet is: <applet code="assumptions.class" archive="popproj.jar" width='760' height='340'> This applet was coded using Java 1.5.0_08-b03.</applet> Instead of the expected text, both browsers said "Loading Java...
3
2376
by: Robert Larsen | last post by:
Hi all I have a small problem with a signed applet. The applet works fine but some users wont click 'yes' to give the applet further privileges (that is ok too). If the user dont give the applet privileges I show a page telling them that the applet wont work unless they grant the applet privileges and give them a link back to the original page so that they can try again if they want to. But if they follow that link, nothing...
2
3458
by: ManidipSengupta | last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in advance for responding. I have made a stub of the codes for better understanding. Situation: I have a Java servlet (HelloWorldServlet) running on a Tomcat (5.5.26) server on a Linux machine (compiled in JDK1.4.2). It writes Javascript to construct...
1
5924
by: Daniel Pitts | last post by:
I only need to support Firefox 3 at the moment, so any advice can be specific to that. I have a Java Applet, lets call it HelperApplet. It has one method of importance: public Object doHelp(JSObject callback) { System.out.println(callback + "\n" + callback.getMember("foo")); callback.call("helped", new Object {callback.getMember("foo")}); return callback;
0
10449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9047
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.