SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help redirecting visitors

    I've got the following script and it works like a charm
    Code:
    <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


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



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

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since there are no answers perhaps i have expressed myself in a bad way. So lets break it down.

    I have the following psuedo code

    Code:
    <html>
    <head>
    <script type="text/javascript">
    function redirect(){
    var theUrlToGoTo = "www.hello.com";
    var myArray = [];
    int size=0;
    for (i=0; i<document.length; i++) {
    if(i == '\\b'+theUrlToGoTo+'\\b')
    size++;
    myArray[i]=allPageTags[i];
    }
    window.onload=redirect();
    </script>
    </head>
    <body>
    <table>
    <tr>
    <td><a href="www.hello1.com">www.hello1.com</a></td>
    </tr>
    <tr>
    <td><a href="www.hello2.com">www.hello2.com</a></td>
    </tr>
    
    </table>
    
    </body>
    </html>
    In other words i want the variable myArray to include the following data

    myArray['www.hello1.com','www.hello2.com'] when i am done.

    How is this done, how do i search a html document with javascript after a certain predefined line?

    Perpahs some soul can edit the above psuedo code so that it actually works?

    Thanks


Bookmarks

Posting Permissions

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