Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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:

    Code:
    <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:

    Code:
    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:

    Code:
    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:

    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
    Last edited by wickland; 06-17-2008 at 10:31 PM.

  • #2
    New Coder
    Join Date
    Dec 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"?

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •