• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Renaming the title bar iin a browser using html

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

When i run my applet, i would like the browser to dynamically display the current job number that has been selected in the title bar of the browser, is there a way to do this using html an JavaScript?

eg: MyProgram Job 2337 - Browser name

Thanks
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try document.title = "new title";
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

That works great, but i need it to be dynamically set getting the variable from the program and i haven't got a clue where to even start, here is my current code:



Any suggestions will be greatly appreciated, thanks.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should have an error message and it should state your issue.

With firefox use the JavaScript console, with IE click the error icon in the status bar.

It is a pretty simple mistake.

Eric
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I checked my log but there weren't any errors, maybe im looking in the wrong log? is there a standers place where the log is? im using fire fox and the only log i know of is the server log, & java console?? I also took out the code that made it scroll so it now looks like:



I have not done html or java script before, so i don't really know if what i am doing is possible.

Thanks for all your help guys.
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The </APPLET> tag is there just missed it when i used copy and paste. thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaScript can't use variables that are declared inside of the applet. And actually, you don't need JavaScript for this - the applet can manipulate the HTML DOM through the Common DOM API.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tools-->Error Console.

With your original example it ran if you declared your speed variable.

Eric
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I read Common DOM API., and although it helped me with the Firefox setting, i am still very confused about how to use dom, java and html together, i have looked at some other web sites to see if i would find anything that would be able to make me understand better, eg: www.webdeveloper.com/forum/showthread , www.stylusstudio.com/xsllist/200108/post50350.html. Is dom normal java? Is it used like a session bean? eg: applet.java --> dom --> applet.html? Or is used in the applet.java class and when the applet is run it sends the variable to the html.

Sorry for all the questions.

//thanks Eric that got it moving

Thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The sylusstudio URL links to something about XSLT - not sure how you got there, but you're on the wrong track; XSLT has nothing to do with this.

The article about the Common DOM API has an example that shows how the applet can retriev the HTML page title; from there it should be easy to figure out how the applet might set the title.

Or does your last comment mean you've been successful with the JavaScript approach?
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, that was the speed value.

I read that example a couple of times but i can't seem to grasp how dom is used? Is it in the java class where the applet code is? Or is it a class by itself that is used like a session bean? At the moment i am reading just java 2 - a program that uses a dom parser but i still can't seem to understand how it connects to html?

Thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at listing 2 in that article. See how it imports the org.w3c.dom.html.* classes? That's the HTML DOM. It's a fairly simple example, so the only code that actually uses the page DOM is this:

It retrieves the HTMLDocument object (the root DOM object of an HTML page) for the HTML page in which the applet lives, and uses that to get the page title. Here's a little hint: that object also has a "setTitle(String)" method :-)
[ December 09, 2008: Message edited by: Ulf Dittmer ]
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lol thanks , im trying to get the example to work first, but whenever it reaches the following line:



It gives me this error:



Is there maybe something i'm missing in my html code? does the
import org.w3c.dom.html.*; have to be in the html or should it be removed?

Thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which JVM version from which vendor are you using? I think the Common DOM API was introduced with the Java Plugin that came with Java 5. So if you're using an earlier JVM this may not work.
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its:

C:\>jview
Microsoft <R> Command-line Loader for Java Version 5.00.3805

So it should work fine?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ouch! You're using the age-old obsolete Microsoft JVM. Run -don't walk- to get rid of it; this page has removal instructions. Then download and install a JVM from java.sun.com; you'll be much happier :-)
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lol my poor computers feelings are hurt! :-) I'm not allowed to hey, the whole system that the program runs on is based on the same version on everyone's pc, they tried to update java on one of the p.c and the system when mad and when they got it running the new code didn't work... So ya.

Any Any Any suggestions?

Thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An alternative way for applets to communicate with JavaScript is called LiveConnect; see here for some related links. That used to work with the MS JVM, but I'm not sure if it still does. Try the mozilla.org test pages linked from that page to see if it works for you. If it does, then you can call a JavaScript method that changes the page title from within the applet (and pass the new title as a parameter).
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Maja Gralewska:
lol my poor computers feelings are hurt! :-) I'm not allowed to hey, the whole system that the program runs on is based on the same version on everyone's pc, they tried to update java on one of the p.c and the system when mad and when they got it running the new code didn't work... So ya.

Any Any Any suggestions?

Thanks



Are you running Netscape 4 and IE 5.5 also. lol [a joke]

Eric
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried that now and it's still not working, but i'm not getting any error messages either: here is all my code... i'm most-probably doing something really stupid but anyways here's my code:

Java class where applet is in:



This is my html code:



Thanks a ton
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lol, what can i say... guess its just my poor pc's destiny to be mocked!!
....you betta just be mocking my pc lol:-)
[ December 09, 2008: Message edited by: Maja Gralewska ]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If fetchJobReference takes a String argument then you better pass a String to it.

I think it's safer to use "document.applets[0]" than "document.DynamicApplet".
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey:-)

Tried what you suggested, still not working & no errors, but now if i put the function code & the code that renames the title bar in the same script it won't rename the title bar even to the default value...

Is it possible to maybe write the variable to destination folder and then call it from the destination folder using html?

Thanks
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's hard to say what might be going wrong with code we don't know.

What do you mean by "destination folder" in the context of a web page?
 
Maja Gralewska
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey

I meant an actual drive with a created folder to where i write the data??
But i don't really see how that could work efficiently?

Its all good tho, tried it on my laptop(has a sun JVM) and it worked hundreds, it just refuses to work on a windows JVM(wierd) so they said i can just leave the default title value for the time being...

Thanks a million tho, you guys really helped me loads

Thanks

[ December 10, 2008: Message edited by: Maja Gralewska ]
[ December 10, 2008: Message edited by: Maja Gralewska ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic