Simple Header Javascript Help

wxdqz

New Member
Hello guys, i'm new to this forum and i'm in need of some simple but hard javascript help. I'm an old programmer and havnt touched anything in years, my mind is gone too all the weed smoke. =( Please bare with me.

Here is my idea and problem...

The URL is what i'm working with, ex <!-- m --><a class="postlink" href="http://www.jayballs.com/main.html?username">http://www.jayballs.com/main.html?username</a><!-- m -->

Now in a little status bar, i'm trying to make this possible,
[[email protected]] (~)$ cat filename.html

here is the code i'm using so far, i know it might be buggy or loops but i have totally been out of the loop too long...

<script language="JavaScript"><!--


var user = '';

var pagename = (window.location.href);

var last_slash = pagename.lastIndexOf("/");
var file_name = last_slash +1;
var page = pagename.substring(file_name, pagename.length);

var host_name = pagename.lastIndexOf("www");
var hostname2 = host_name ;
var hostname = pagename.substring(hostname2, pagename.length);

var host_name2 = (hostname.lastIndexOf("/")-hostname.length);
var realhost = hostname.substring(hostname.length, host_name2);


var login = location.search.indexOf('=');
var user = location.search.substring(login+2);

if (user == '') { document.write('[guest@' + realhost + '] (~)$ cat ' + page + '') };
else { document.write('[' + user + '@' + realhost + '] (~)$ cat ' + page + '') };


//--></script>

I only real problems is i dont know how to striped out the text from behind ex, i can get <!-- w --><a class="postlink" href="http://www.jayballs.com/main.html?username">www.jayballs.com/main.html?username</a><!-- w --> how i do isolate <!-- w --><a class="postlink" href="http://www.jayballs.com">www.jayballs.com</a><!-- w --> and main.html dropping the ?username and the <!-- m --><a class="postlink" href="http://'s">http://'s</a><!-- m -->

Any help would be GREATLY needed and thanked for.
 
Back
Top