Click to See Complete Forum and Search --> : Simple Header Javascript Help


pimpy
12-16-2002, 04:48 PM
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 http://www.jayballs.com/main.html?username

Now in a little status bar, i'm trying to make this possible,
[username@hostname.com] (~)$ 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 www.jayballs.com/main.html?username how i do isolate www.jayballs.com and main.html dropping the ?username and the http://'s

Any help would be GREATLY needed and thanked for.

pimpy
12-16-2002, 05:24 PM
So no one can help me? Its a really simple script that I just cant do cause i dont know javascript...


My main frame gets sent this URL, http://www.jayballs.com/main.html?guest

I need a javascript code to isolate the www.jayballs.com, the main.html and the ?guest without the ? in the var... I dont know what statements to use, can anyone help me write this script please???


Thanks