1. No Profile Picture
    php newbie
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Rep Power

    javascript to server side

    I heard it was possible to have server side javascript. But is that Java or JSP then or is it completely different?

    I have this script and i would like to make it a server side script, preferably with javascript. It modifies the url on click. I wanted to know how to make it server-side and if i need to make any changes to it. Thanks.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <title>Abe Linkin' Returns</title>
    <script type="text/javascript" language="javascript">
    var redirURL = 'www.domain.com/abc.php?';
    function linkRedir(e) {
    var src = window.event ? event.srcElement : e.target ? e.target : null;
    if (typeof src == 'undefined') return true;
    if ((src.tagName && src.tagName.toUpperCase() == 'A' && src.href) || (e && src.href)) {
    var host = src.hostname.split('.')[0];
    var path = src.pathname.replace(/\//, '');
    readout.value = redirURL + 'site=' + host + '&dir=' + path;
    return false;
    return true;
    if (document.captureEvents) document.captureEvents(Event.CLICK);
    document.onclick = linkRedir;
    <body onload="window.readout=document.forms[0].readout">
    <form><input type="text" name="readout" size="48"></form>
    <a href="http://mysite.com/music">| href="http://mysite.com/music" |</a><br><br>
    <a href="http://somesite.com/cars">| href="http://somesite.com/cars" |</a><br><br>
    <a href="http://yech.com/goo">| href="yech.com/goo" |</a><br><br>
    This is code i got from a question i asked from the javascript forum.
    "They have the internet on computers now" - Homer
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Sacramento, CA
    Rep Power
    Well, I know that ASP pages can be written in Javascript. I think with netscape's webserver you could put javascript in <server> tags and have it execute on the server. I'm not sure if any other servers support that, though.

    Looks like some java app servers support writing jsp pages in javascript, too:

    ***edit [part 2]***
    Of course, now that I've actually *read* your code ...
    It won't work server-side, no matter what server you find. You're doing event processing, which means you're interacting with the user, which means you have to run the script client-side. You could pass the src attribute to the server using a form, then processes it there, though. If you do that, I'd suggest just sticking with your php.
    Last edited by bricker42; December 23rd, 2002 at 11:36 PM.
  4. #3
  5. No Profile Picture
    php newbie
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Rep Power
    Thank you for your answer

    So javascript for this on the server is a no go. I'll try php so see if it works, somehow.

    Thanks for your help again!
    "They have the internet on computers now" - Homer

IMN logo majestic logo threadwatch logo seochat tools logo