...

View Full Version : language="JavaScript" works but type="text/javascript" doesn't, please help!



wickland
06-17-2008, 12:56 AM
My website is at www.mysite.com. The script in question is the language translator at the very top of the page with 13 flags.

The original working script code is:


<script language="JavaScript" src="http://www.mysite.com/websitetranslator/flags.php"></script>

BUT, this script doesn't validate with HTML 4.01, W3C says I need to add a "type" attribute. So I add type="text/javascript". When you click on a flag and translate the page, but then keep clicking on the flags, the URL grows into a huge nasty mess like:


http://www.mysite.com/it/ja/de/ie/ja/de/ie/fr/fr/fr/fr/fr/mypage.php

The correct script isn't supposed to be piling up those extensions. Does anyone know what the correct "type" attribute equivalent of language="javascript" is that will make this script work correctly? Please let me know if you need any additional code or pages.

the flags.php that the scripts call code is:


document.write('<a href="http://'+window.location.hostname+'/fr'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_fr.gif" alt="Fran&#231;ais" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/es'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_es.gif" alt="Espa&#241;ol" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/ja'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_ja.gif" alt="日本語" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/ar'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_ar.gif" alt="[أربيك]" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/it'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_it.gif" alt="Italiano" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/de'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_de.gif" alt="Deutsch" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/zh'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_zh-chinese.gif" alt="汉语" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/nl'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_nl.gif" alt="Nederlands" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/ko'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_ko.gif" alt="한국어" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/pt'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_pt.gif" alt="Port" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/ru'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_ru.gif" alt="Русско" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+'/id'+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_id.gif" alt="Indo" width="18" height="12" border="0"></a> ');
document.write('<a href="http://'+window.location.hostname+''+window.location.pathname+'"><img src="http://'+window.location.hostname+'/websitetranslator/images/flag_en.gif" alt="English - Original language" width="18" height="12" border="0"></a> ');

.htaccess code:


RewriteEngine On
RewriteRule ^fr/(.*)$ /websitetranslator/index.php?lang=fr&url=$1 [L,QSA]
RewriteRule ^es/(.*)$ /websitetranslator/index.php?lang=es&url=$1 [L,QSA]
RewriteRule ^ja/(.*)$ /websitetranslator/index.php?lang=ja&url=$1 [L,QSA]
RewriteRule ^ar/(.*)$ /websitetranslator/index.php?lang=ar&url=$1 [L,QSA]
RewriteRule ^it/(.*)$ /websitetranslator/index.php?lang=it&url=$1 [L,QSA]
RewriteRule ^de/(.*)$ /websitetranslator/index.php?lang=de&url=$1 [L,QSA]
RewriteRule ^zh/(.*)$ /websitetranslator/index.php?lang=zh&url=$1 [L,QSA]
RewriteRule ^nl/(.*)$ /websitetranslator/index.php?lang=nl&url=$1 [L,QSA]
RewriteRule ^ko/(.*)$ /websitetranslator/index.php?lang=ko&url=$1 [L,QSA]
RewriteRule ^pt/(.*)$ /websitetranslator/index.php?lang=pt&url=$1 [L,QSA]
RewriteRule ^ru/(.*)$ /websitetranslator/index.php?lang=ru&url=$1 [L,QSA]
RewriteRule ^id/(.*)$ /websitetranslator/index.php?lang=id&url=$1 [L,QSA]

I would really appreciate your help.

Thanks,
Noob

wickland
06-17-2008, 02:33 AM
What is the difference between type="text/javascript" and language="JavaScript" in terms of getting a script to work?

Why would language="JavaScript" work but not type="text/javascript"?

wickland
06-17-2008, 04:50 AM
I believe I have found away around it. Thanks for the help

To the Moderator, could you please delete this thread or at least my website URL?

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum