Forum Moderators: open

Message Too Old, No Replies

Making translation buttons

Picking up the current page for a JAVA applet to use

         

gleckert

1:29 am on Jul 29, 2003 (gmt 0)

10+ Year Member



Ok, here are the details:
I have set up a java button bar on my include page that is part of every page on my site. It is written in Java. I would like it to automatically detect the URL for the current page and translate (using google) into one of several different languages. Here is the code I have so far (you can also see it at <edit>):

<applet Code="apButtonMenu.class" Archive="http://www.example.com/apButtonMenu.jar" Width="552" Height="18">
<param name="backColor" value="000000">
<param name="backHighColor" value="845708">
<param name="fontColor" value="AA0000">
<param name="fontHighColor" value="ffffff">
<param name="font" value="Courier,13,1">
<param name="isHorizontal" value="true">
<param name="buttonType" value="3">
<param name="status" value="link">
<param name="menuItems" value="
{Deutsch,http://translate.google.com/translate?u=(current document url)&langpair=en¦de&hl=en&ie=UTF-8&oe=UTF-8,_self}
{Français,http://translate.google.com/translate?u=(current document url)&langpair=en¦fr&hl=en&ie=UTF-8&oe=UTF-8,_self}
{Español,http://translate.google.com/translate?u=(current document url)&langpair=en¦es&hl=en&ie=UTF-8&oe=UTF-8,_self}
{Italiano,http://translate.google.com/translate?u=(current document url)&langpair=en¦it&hl=en&ie=UTF-8&oe=UTF-8,_self}
{Portuguese,http://translate.google.com/translate?u=(current document url)&langpair=en¦pt&hl=en&ie=UTF-8&oe=UTF-8,_self}">
</applet>

So the problem is how do I make the (current document url) part of each line item work? I just can't seem to get that piece of it. Please help!

[edited by: tedster at 1:49 am (utc) on July 29, 2003]

RobbieD

1:35 am on Jul 29, 2003 (gmt 0)

10+ Year Member



The following script generates the current url of the page, without the hyperlink.

<SCRIPT LANGUAGE="JavaScript">

<!--
{
document.write(location.href);
}
// -->
</SCRIPT>

The following script generates the current url of the page, with the hyperlink.

<SCRIPT LANGUAGE="JavaScript">

<!--
document.write('<A HREF="' + location.href +'">');
document.write(location.href);
document.write('</A>');
// -->
</SCRIPT>

Also, I would suggest you use a .js tag for your code. Search engines like it and you can edit it easier.

This might give you ideas...