Did 15 mins of Google searching, nothing useful. As the thread location suggests, I am working in HTML. No switching for me at this point in time.
So here's what I want. I have a Dutch section (/nl/) and an English section (/en/)of my website. In my navigation bar I have 2 flags representing each language. Is it possible to link the user to the same file but in a different directory if they click one of the flags? So if they are on /nl/about.html, and they click on the English flag, they are linked to /en/about.html.
By the way I am using dwt's (Dreamweaver Templates), so that's why I would want one piece of code and be done with it.
Not really sure what the problem here is, it wouldn't be linking to the 'same' file if its in a different directory, you'd have to make two copies of the file and place one in /nl/ and one in /en/.
I found this useful script on the www which returns the basename of your web page's current url.
If you set the suffix argument to an empty string you get the full base name including filename extension.
If you set a suffix like '.htm', you get the basename minus the suffix, assuming your url ends in .htm
You then only need to append it to the directory path to the alternate language folder on your site and then redirect your browser using JS to the new url.
I'm not a Dreamweaver user so I don't know how to integrate this script into your code. Maybe someone else can help or offer a better solution.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function basename(path, suffix) {
// Returns the filename component of the path
//
// version: 910.820
// discuss at: http://phpjs.org/functions/basename // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Ash Searle (http://hexmen.com/blog/)
// + improved by: Lincoln Ramsay
// + improved by: djmix
// * example 1: basename('/www/site/home.htm', '.htm'); // * returns 1: 'home'
// * example 2: basename('ecra.php?p=1');
// * returns 2: 'ecra.php?p=1'
var b = path.replace(/^.*[\/\\]/g, '');
if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
b = b.substr(0, b.length-suffix.length);
}
//return b;
alert(b);
}
</script>
</head>
<body onload="basename(window.location.href,'');">
<h1>hello world</h1>
</body>
</html>
Not really sure what the problem here is, it wouldn't be linking to the 'same' file if its in a different directory, you'd have to make two copies of the file and place one in /nl/ and one in /en/.
I should have been more clear. I want it to link to a file with the same NAME as the current file, but in a different directory.
I found this useful script on the www which returns the basename of your web page's current url.
If you set the suffix argument to an empty string you get the full base name including filename extension.
If you set a suffix like '.htm', you get the basename minus the suffix, assuming your url ends in .htm
You then only need to append it to the directory path to the alternate language folder on your site and then redirect your browser using JS to the new url.
I'm not a Dreamweaver user so I don't know how to integrate this script into your code. Maybe someone else can help or offer a better solution.
Thanks a lot for the effort, it's a pity that my Javascript skills suck. I think I know for about 1/4 what that all means. Maybe less even...
If someone would like to help me out it would be awesome, but I guess I'm not really asking for it, since a solution has been given, and if I start learning Javascript now, I could do it. The thing is, I would love to learn Javascript, but I would also love to have my website up and running in about a week.
So if anyone wants to help me with this it would be freakin great.
Oops as I was going through my tabs I noticed I spelled "Like" instead of "Link" I don't think I have the privilege to change this, can someone do this please? That way other people can find it too
Bookmarks