Bottom of This Page |
Redirect / Omdiriger
Description: Split a HTML (HyperText Markup Language)
document's URL (Uniform Resource Locator) up
in parts
Overview - Function(s)... / Oversigt - Funktion(er)...
Developed and tested under browser(s): Microsoft Internet Explorer Version 8.x. / Udviklet og testet under browser(e): Microsoft Internet Explorer Version 8.x.
<HEAD></HEAD>
section
of your HTML (HyperText Markup Language) document. /
<HEAD></HEAD>
sektionen
af dit HTML (HyperText Markup Language) dokument.
<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript Applet and hide from old browsers -----
// Initialize variables for global use.
var loc = location.href; // href location of document.
loc = loc.toString();
loc = loc.toLowerCase();
var lenptype = loc.indexOf(":"); // Length of the protocol type (such as http:, ftp:, gopher:, and so on).
var ptype = loc.substring(0,(lenptype + 1)); // Extract the protocol type characters from pos 0 up to but not including pos ('lenptype' + 1).
if ( ptype == "file:" ) {
var docLocal = true; // Document Local.
} else {
var docLocal = false; // Document not Local.
}
var loc_href = self.location.href; // href location of document.
loc_href = loc_href.toString();
//loc_href = loc_href.toLowerCase();
var loc_path = self.location.pathname; // Pathname location of document.
loc_path = loc_path.toString();
//loc_path = loc_path.toLowerCase();
var loc_search = self.location.search; // Search location of document.
loc_search = loc_search.toString();
//loc_search = loc_search.toLowerCase();
var questionMarkConstant = "?"; // Question mark constant.
var equalSignConstant = "="; // Equal-sign constant.
var ampersandConstant = "&"; // Ampersand constant.
var TypedURL; // Typed URL.
var goLocation; // Go to location (URL).
var openLocation; // Open location (URL).
var urlPart1Str; // Stores URL (Uniform Resource Locator) Part 1 of URL (Uniform Resource Locator).
var urlPart2Str; // Stores URL (Uniform Resource Locator) Part 2 of URL (Uniform Resource Locator). [ This document's drive letter. ]
var urlPart3Str; // Stores URL (Uniform Resource Locator) Part 3 of URL (Uniform Resource Locator).
var urlPart4Str; // Stores URL (Uniform Resource Locator) Part 4 of URL (Uniform Resource Locator). [ This document's file name. ]
var urlPart5Str; // Stores URL (Uniform Resource Locator) Part 5 of URL (Uniform Resource Locator).
TypedURL = "";
goLocation = "";
openLocation = "";
urlPart1Str = "";
urlPart2Str = "";
urlPart3Str = "";
urlPart4Str = "";
urlPart5Str = "";
// Split this document's URL (Uniform Resource Locator) up in parts - but only URLs from a Hard Disk Drive.
// The method charAt is used to extract a single character from a
// string at start position.
// The method substring is used to extract a range of characters
// from a string from start position up to but not including end
// position.
// The method indexOf is used to search for character with a string -
// searches from the beginning (left side) of the string. Optional
// second argument that specifies an initial index at which to start
// the search.
// The method lastIndexOf is used to search for character with a
// string - searches from the end (right side) of the string.
// Optional second argument that specifies an initial index at
// which to start the search.
// Character positions are zero based, so that all indices must fall
// between 0 and one less than the length.
// In JavaScript, the backslash (\) is an escape character.
// An escape character enables you to output characters you wouldn't
// normally be able to, usually because the browser will interpret it
// differently to what you intended.
if ( docLocal ) {
// Document Local.
if ( loc_href.indexOf("/",0) != -1 ) {
// The slash (/) is used as separator in the string.
urlPart1Str = "" + loc_href.substring(0,(loc_href.indexOf(loc_path,0)+1)); // Force number to a string.
urlPart2Str = "" + loc_path.charAt(1); // Force number to a string.
urlPart3Str = "" + loc_href.substring((loc_href.indexOf(loc_path,0)+2),((urlPart1Str.length-1)+loc_path.length)); // Force number to a string.
urlPart4Str = "" + urlPart3Str.substring((urlPart3Str.lastIndexOf("/")+1),urlPart3Str.length); // Force number to a string.
urlPart3Str = "" + urlPart3Str.substring(0,(urlPart3Str.length-urlPart4Str.length)); // Force number to a string.
urlPart5Str = "" + loc_href.substring((urlPart1Str.length+urlPart2Str.length+urlPart3Str.length+urlPart4Str.length),loc_href.length); // Force number to a string.
} else if ( loc_href.indexOf("\\",0) != -1 ) {
// The backslash (\) is used as separator in the string.
urlPart1Str = "" + loc_href.substring(0,(loc_href.indexOf(loc_path,0)+1)); // Force number to a string.
urlPart2Str = "" + loc_path.charAt(1); // Force number to a string.
urlPart3Str = "" + loc_href.substring((loc_href.indexOf(loc_path,0)+2),((urlPart1Str.length-1)+loc_path.length)); // Force number to a string.
urlPart4Str = "" + urlPart3Str.substring((urlPart3Str.lastIndexOf("\\")+1),urlPart3Str.length); // Force number to a string.
urlPart3Str = "" + urlPart3Str.substring(0,(urlPart3Str.length-urlPart4Str.length)); // Force number to a string.
urlPart5Str = "" + loc_href.substring((urlPart1Str.length+urlPart2Str.length+urlPart3Str.length+urlPart4Str.length),loc_href.length); // Force number to a string.
}
} else {
// Document not Local.
// Do nothing.
//;
}
//alert("URL - Part 1: \"" + urlPart1Str + "\", Part 2 (drive letter): \"" + urlPart2Str + "\", Part 3: \"" + urlPart3Str + "\", Part 4 (file name): \"" + urlPart4Str + "\", and Part 5: \"" + urlPart5Str + "\"."); // Only for the purpose of debugging.
function jump_menu() {
// This function supports the UNIT jump menu
// and jumps directly to the page in
// the variable 'goLocation'.
// Find out what is currently selected.
var loc = document.info.jumpMenu.options[document.info.jumpMenu.selectedIndex].value;
var goLocation = "-"; // Go to location (URL).
// Give the person the page they selected.
if (loc == " "){
goLocation = "-";
}else{
goLocation = "" + urlPart1Str + loc + urlPart3Str + urlPart4Str + urlPart5Str; // Force number to a string.
}
if (goLocation != "-"){
top.location = goLocation;
}else{
alert("Select something.");
}
return;
}
function openPopUpURLjm() {
// This function supports the UNIT jump menu
// and jumps directly to the page in
// the variable 'goLocation' (Opens in a new Pop Up window).
// Find out what is currently selected.
var loc = document.info.jumpMenu.options[document.info.jumpMenu.selectedIndex].value;
var goLocation = "-"; // Go to location (URL).
// Give the person the page they selected.
if (loc == " "){
goLocation = "-";
}else{
goLocation = "" + urlPart1Str + loc + urlPart3Str + urlPart4Str + urlPart5Str; // Force number to a string.
}
if (goLocation != "-"){
// alert("URL GO to: \"" + goLocation + "\".");
openLocation = goLocation;
//alert("Sorry, the page '" + openLocation + "' you requested was not found.");
var aPopUp = window.open(openLocation,"PopUpURLjm","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=450,height=500");
}else{
alert("Select something.");
}
return;
}
function doOnLoad()
{
// Dynamically change the selections made.
document.info.jumpMenu.options[0].selected=1;
document.info.output.value = "" + urlPart1Str; // Output. // Force number to a string.
document.info.output2.value = "" + urlPart3Str + urlPart4Str + urlPart5Str; // Output. // Force number to a string.
return;
}
// - End of JavaScript code and done hiding -->
</SCRIPT>
Conventions used for: Source code syntax highlighting. / Regler brugt til: Kildekode syntaks fremhævning.
<BODY>
tag
of your HTML (HyperText Markup Language) document. /
<BODY>
tag'get
af dit HTML (HyperText Markup Language) dokument.
<BODY onLoad="window.setTimeout('doOnLoad();',1000)">
Conventions used for: Source code syntax highlighting. / Regler brugt til: Kildekode syntaks fremhævning.
<BODY></BODY>
section
of your HTML (HyperText Markup Language) document. /
<BODY></BODY>
sektionen
af dit HTML (HyperText Markup Language) dokument.
<p> </p>
<CENTER>
<DIV ALIGN="CENTER">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD ALIGN="LEFT" VALIGN="MIDDLE">
<FORM NAME="info">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD ALIGN="LEFT" VALIGN="MIDDLE" bgcolor="#FFFFFF" NOWRAP> </TD>
<TD ALIGN="RIGHT" VALIGN="MIDDLE" bgcolor="#FFFFFF" NOWRAP>
<INPUT TYPE="text" NAME="output" SIZE="20"
onFocus="this.blur()"
onSubmit="return false" ><!--
--></TD>
<TD ALIGN="RIGHT" VALIGN="MIDDLE" bgcolor="#FFFFFF" NOWRAP>
<select NAME="jumpMenu">
<OPTION VALUE=" " SELECTED> </OPTION>
<OPTION VALUE="A"> A</OPTION>
<OPTION VALUE="B"> B</OPTION>
<OPTION VALUE="C"> C</OPTION>
<OPTION VALUE="D"> D</OPTION>
<OPTION VALUE="E"> E</OPTION>
<OPTION VALUE="F"> F</OPTION>
<OPTION VALUE="G"> G</OPTION>
<OPTION VALUE="H"> H</OPTION>
<OPTION VALUE="I"> I</OPTION>
<OPTION VALUE="J"> J</OPTION>
<OPTION VALUE="K"> K</OPTION>
<OPTION VALUE="L"> L</OPTION>
<OPTION VALUE="M"> M</OPTION>
<OPTION VALUE="N"> N</OPTION>
<OPTION VALUE="O"> O</OPTION>
<OPTION VALUE="P"> P</OPTION>
<OPTION VALUE="Q"> Q</OPTION>
<OPTION VALUE="R"> R</OPTION>
<OPTION VALUE="S"> S</OPTION>
<OPTION VALUE="T"> T</OPTION>
<OPTION VALUE="U"> U</OPTION>
<OPTION VALUE="V"> V</OPTION>
<OPTION VALUE="W"> W</OPTION>
<OPTION VALUE="X"> X</OPTION>
<OPTION VALUE="Y"> Y</OPTION>
<OPTION VALUE="Z"> Z</OPTION>
</select>
</TD>
<TD ALIGN="LEFT" VALIGN="MIDDLE" bgcolor="#FFFFFF" NOWRAP><!--
--><INPUT TYPE="text" NAME="output2" SIZE="60"
onFocus="this.blur()"
onSubmit="return false" ><!--
-->
</TD>
<TD ALIGN="LEFT" VALIGN="MIDDLE" bgcolor="#FFFFFF" NOWRAP> </TD>
<TD ALIGN="LEFT" VALIGN="MIDDLE" NOWRAP> </TD>
<TD ALIGN="LEFT" VALIGN="MIDDLE" NOWRAP><INPUT TYPE="button" NAME="GoUrlBtn1jm" VALUE="GO!" onClick="jump_menu()"></TD>
<TD ALIGN="LEFT" VALIGN="MIDDLE" NOWRAP> </TD>
<TD ALIGN="LEFT" VALIGN="MIDDLE" NOWRAP><INPUT TYPE="button" NAME="GoUrlBtn2jm" VALUE="GO (new window)!" onClick="openPopUpURLjm()"></TD>
</TR>
</TABLE>
</FORM>
</TD>
</TR>
</TABLE>
</DIV>
</CENTER>
<p> </p>
Conventions used for: Source code syntax highlighting. / Regler brugt til: Kildekode syntaks fremhævning.
The next 2 pages linked to in the next 2 links below will only work when the pages are downloaded**) and saved on your computer. / De næste 2 sider linket til i de næste 2 links nedenfor vil kun virke, når siderne er download'et**) og gemt på din computer.
Purpose: / Formål:
When this code is added to a HTML (HyperText Markup Language) page you will be able to change to a similar page with the same file name placed in exactly the same directory structure on another optional drive. / Når denne kode føjes til en HTML (HyperText Markup Language) side, vil du være i stand til at skifte til en tilsvarende side med det samme filnavn placeret i præcis samme mappe struktur på et andet valgfrit drev.
You can download**) a version of the source code here: / Du kan downloade**) en version af kildekoden her:
[JavaScript (JScript)] Download Redirect: redirask.htm / [JavaScript (JScript)] Download Omdiriger: redirask.htm*)
*) Automatically redirect page. / Automatisk omdiriger side.
**) How to download a file to your computer: Simply click the RIGHT mouse button over the graphic "Link" Image. From the popup menu, Netscape users will select "Save link as" and Internet Explorer users will select "Save destination as". / Sådan downloades en fil til din computer: Klik simpelt hen på den HØJRE museknap over grafik "Link" billedet. Fra pop-up menuen skal Netscape brugere vælge "Gem link som" og Internet Explorer brugere vælge "Gem destination som".
See (and download**)) similar source code for JavaScript here: / Se (og download**)) tilsvarende kildekode for JavaScript her:
Purpose: / Formål:
With this HTML (HyperText Markup Language) page you will be able to change to a predefined page with a predefined file name placed in a predefined directory structure on another optional drive. / Med denne HTML (HyperText Markup Language) side vil du være i stand til at skifte til en foruddefineret side med et foruddefineret filnavn placeret i en foruddefineret mappe struktur på et andet valgfrit drev.
[JavaScript (JScript)] Download ! Go Index: go_index.htm / [JavaScript (JScript)] Download ! Go Index: go_index.htm*)
*) Automatically redirect page. / Automatisk omdiriger side.
**) How to download a file to your computer: Simply click the RIGHT mouse button over the graphic "Link" Image. From the popup menu, Netscape users will select "Save link as" and Internet Explorer users will select "Save destination as". / Sådan downloades en fil til din computer: Klik simpelt hen på den HØJRE museknap over grafik "Link" billedet. Fra pop-up menuen skal Netscape brugere vælge "Gem link som" og Internet Explorer brugere vælge "Gem destination som".
The code might need some minor tweaks to run in your application. / Koden kan behøve nogle mindre ændringer for at kunne afvikles i dit anvendelsesområde.
Licence: Free to use, but please
share improvements.
No warranty - use at own risk. /
Licens: Fri brug, men
del venligst forbedringer.
Ingen garanti - brug på eget ansvar.
Warning: Don't run the script files
without reading them first!
Total absence of any guarantee, warranty, or
responsibility for script files, the script(s), the files they
may produce, or the effects the script(s) or script-produced
files may have. The script(s) is, after all, plain text. The
burden is on the person using the script(s) to examine
the script source code and determine whether or not a script is
usable and safe. Operating systems and browsers are constantly
changing. What works today may not work tomorrow!
Advarsel: Kør ikke script-filerne
uden at læse dem først!
Totalt fravær af nogen form for garanti,
garanti eller ansvar for script-filer, scriptet(scriptene), de
filer, de kan producere eller de virkninger, scriptet(scriptene)
eller scriptproducerede filer kan have. Scriptet(Scriptene) er,
trods alt, almindelig tekst. Byrden er på brugeren af
scriptet(scriptene) til at undersøge script kildekoden og
afgøre, hvorvidt et script er brugbart og sikkert.
Operativsystemer og browsere er under konstant forandring. Hvad
fungerer i dag, fungerer muligvis ikke i morgen!
|