I’ve got the following script and it works like a charm
<script type="text/javascript">
var currentUrl = window.location.href;
function goToPath() {
var theUrlToGoTo = "http://someRandomSite";
var aPosition = currentUrl.indexOf("Name_");
aPosition=currentUrl.indexOf("/", (aPosition))+1;
var secondPos = currentUrl.indexOf("/", aPosition);
return theUrlToGoTo.concat("/").concat(currentUrl.substring(aPosition, secondPos)).concat("/summary.shtml");
}
<!--
window.location=goToPath();
//-->
</script>
Now to my problem
Sometimes there are two similar addresses, so for example
if there are two links that are similar that i can click on, for example
<html>
<td><a href="href="http://someOtherRandomSite/Name_/index.html"">RandomName</a>
<td><a href="href="http://someOtherRandomSite/Name_hi2/index.html"">Name1</a>
<td><a href="href="http://someOtherRandomSite/Name_hi1/index.html"">Name2</a>
In the above example there are two similar links “Hi1, Hi2”. In these cases I want it to generate a new webpage with the name of this two and links to them.
example
<html>
<body>
<td><a href="href="http://someRandomSite/Name_hi1/Summary.shtml"">Name1</a>
<td><a href="href="http://someRandomSite/Name_hi2/Summary.shtml"">Name2</a>
</body>
</html>
Can this be done by javascript,
first check when you click on a random adress if there are two(ore more) similar adresses and then generate and direct to a new webpage with those similar addresses with links to them?
(Dont mind if the script is incorrect, it works as is should)