Pewit
07-28-2005, 08:08 AM
Hi There
I have two frames - topFrame containing menus and mainFrame with the content. When mainFrame loads it writes a script that creates buttons which on click passes the mainFrame content to the Google translation site and writes the translated version translation tools into the mainFrame.
Issues
My problem is that when the translated version is written, Google creates a frame on the botom of the topFrame and the translated page in the mainFrame.
1. I want the both Google frame header and the translation to appear in the mainFrame.
2. I need to be able to remove the Google frame header if the user clicks on the "Original English" button.
3. The original script has a function (see Bust Out below) that if I leave it in, it refreshes the mainFrame on load and removes my topFrame. Ideally, I only want this function only to be called when a user presses the "Original English" button and have the mainFrame refresh but without the Google frame.
// JS.Translator.Front-End (en-to-all v1.1)
// Copyright 2004 Shawn Brown (http://www.shawnbrown.com)
var flag_folder_url = "http://www.mysite.com/images/";
var flag_alignment = "h";
var to_translaton_heading = "Click flag to translate<br>";
var to_original_heading = "Click flag for Original<br>";
// SCRIPT BEGINS -- DO NOT CHANGE AFTER THIS POINT
// Function returns a single HTML-formatted hyperlink using a flag graphic.
function translation_link(hl_equals,lp,flag_file,title)
{
var orig_url = document.location.href;
orig_url = orig_url.slice(7, orig_url.length);
escape(orig_url);
if (orig_url.search("%3F") > -1)
orig_url = orig_url.slice(0, orig_url.search("%3F"));
translation_url = "http://translate.google.com/translate?u=http%3A%2F%2F"
// + hl_equals
+ orig_url
+ "&langpair="
+ lp
+ "&hl=en&safe=of&ie=UTF8"
+ "&prev=%2Flanguage_tools";
full_link = "<a href='" + translation_url + "' title='" + title + "'>"
+ "<img src='" + flag_folder_url + flag_file + "' width='20' height='10' border='0' hspace='1'>"
+ "</a>";
if (flag_alignment == "v")
full_link = full_link + "<br>";
return (full_link)
}
// If the page has not been loaded by Google's translator, then write the link flags.
if (document.location.hostname != "216.239.39.104" &&
document.location.hostname != "216.239.37.104" &&
document.location.hostname != "translate.google.com")
{
trans_links = translation_link("de","en|de","fl_de_sm.gif","Deutsch")
+ translation_link("es","en|es","fl_es_sm.gif","Español")
+ translation_link("fr","en|fr","fl_fr_sm.gif","Français")
document.write(to_translaton_heading + trans_links);
}
// Else, the page has been translated. Write the back-to-English link flag.
else
{
var orig_url = document.location.href;
orig_url = orig_url.slice(7, orig_url.length);
orig_url = orig_url.slice(orig_url.search("http"), orig_url.length);
if (orig_url.search("&") > -1)
orig_url = orig_url.slice(0, orig_url.search("&"));
var original_link = "<a href='" + orig_url + "' title='Original English'>"
+ "<img src='" + flag_folder_url + "flag_english.gif'" + " width='30' height='20' border='0'>"
+ "</a>";
document.write(to_original_heading + original_link);
// document.write("<br><br>REFERER<br>" + document.location.referer);
};
// Bust out of Google's frame if we're not looking at a translated page.
if (top != self &&
document.location.hostname != "216.239.39.104" &&
document.location.hostname != "216.239.37.104" &&
document.location.hostname != "translate.google.com")
top.location.replace(unescape(mainFrame.location.pathname));
// SCRIPT ENDS
Thanks for any suggestions
I have two frames - topFrame containing menus and mainFrame with the content. When mainFrame loads it writes a script that creates buttons which on click passes the mainFrame content to the Google translation site and writes the translated version translation tools into the mainFrame.
Issues
My problem is that when the translated version is written, Google creates a frame on the botom of the topFrame and the translated page in the mainFrame.
1. I want the both Google frame header and the translation to appear in the mainFrame.
2. I need to be able to remove the Google frame header if the user clicks on the "Original English" button.
3. The original script has a function (see Bust Out below) that if I leave it in, it refreshes the mainFrame on load and removes my topFrame. Ideally, I only want this function only to be called when a user presses the "Original English" button and have the mainFrame refresh but without the Google frame.
// JS.Translator.Front-End (en-to-all v1.1)
// Copyright 2004 Shawn Brown (http://www.shawnbrown.com)
var flag_folder_url = "http://www.mysite.com/images/";
var flag_alignment = "h";
var to_translaton_heading = "Click flag to translate<br>";
var to_original_heading = "Click flag for Original<br>";
// SCRIPT BEGINS -- DO NOT CHANGE AFTER THIS POINT
// Function returns a single HTML-formatted hyperlink using a flag graphic.
function translation_link(hl_equals,lp,flag_file,title)
{
var orig_url = document.location.href;
orig_url = orig_url.slice(7, orig_url.length);
escape(orig_url);
if (orig_url.search("%3F") > -1)
orig_url = orig_url.slice(0, orig_url.search("%3F"));
translation_url = "http://translate.google.com/translate?u=http%3A%2F%2F"
// + hl_equals
+ orig_url
+ "&langpair="
+ lp
+ "&hl=en&safe=of&ie=UTF8"
+ "&prev=%2Flanguage_tools";
full_link = "<a href='" + translation_url + "' title='" + title + "'>"
+ "<img src='" + flag_folder_url + flag_file + "' width='20' height='10' border='0' hspace='1'>"
+ "</a>";
if (flag_alignment == "v")
full_link = full_link + "<br>";
return (full_link)
}
// If the page has not been loaded by Google's translator, then write the link flags.
if (document.location.hostname != "216.239.39.104" &&
document.location.hostname != "216.239.37.104" &&
document.location.hostname != "translate.google.com")
{
trans_links = translation_link("de","en|de","fl_de_sm.gif","Deutsch")
+ translation_link("es","en|es","fl_es_sm.gif","Español")
+ translation_link("fr","en|fr","fl_fr_sm.gif","Français")
document.write(to_translaton_heading + trans_links);
}
// Else, the page has been translated. Write the back-to-English link flag.
else
{
var orig_url = document.location.href;
orig_url = orig_url.slice(7, orig_url.length);
orig_url = orig_url.slice(orig_url.search("http"), orig_url.length);
if (orig_url.search("&") > -1)
orig_url = orig_url.slice(0, orig_url.search("&"));
var original_link = "<a href='" + orig_url + "' title='Original English'>"
+ "<img src='" + flag_folder_url + "flag_english.gif'" + " width='30' height='20' border='0'>"
+ "</a>";
document.write(to_original_heading + original_link);
// document.write("<br><br>REFERER<br>" + document.location.referer);
};
// Bust out of Google's frame if we're not looking at a translated page.
if (top != self &&
document.location.hostname != "216.239.39.104" &&
document.location.hostname != "216.239.37.104" &&
document.location.hostname != "translate.google.com")
top.location.replace(unescape(mainFrame.location.pathname));
// SCRIPT ENDS
Thanks for any suggestions