Script doesn't function when "served"

Discussion in 'JavaScript' started by dtolpin, May 29, 2009.

  1. #1
    I'm re-educating myself after a long period away from PHP and Javascript. I'm totally perplexed.

    I've got a tiny script that illustrates my problem:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <script type="text/javascript" language="JavaScript">
    function myfunction(txt)
    {
    alert(txt);
    }
    </script>
    </head>
    <body>

    <form>
    <input type="button" onclick="myfunction('Hello')" value="Call function">
    </form>

    <p>By pressing the button above, a function will be called with "Hello" as a parameter. The function will alert the parameter.</p>

    <br />
    <a href="javascript: myfunction('Goodbye')">TEST</a>

    </body>
    </html>

    When I send this page, using either a local or remote server, to any of my browsers, the javascript function does not work.

    If I open this "file" using any browser, It works perfectly.

    When I view the source either "served" or "opened" the text is identical.

    What am I missing?

    TIA,

    Dick Tolpin
    dtolpin@cdp.com
     
    dtolpin, May 29, 2009 IP
  2. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Worked for me on my server. Where did you "upload" it to?
     
    GreatMetro, May 29, 2009 IP
  3. dtolpin

    dtolpin Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Originally I used my local server (XAMPP Linux installation on my windows machine). Then I uploaded the files to an active Linux server hosted by 1and1. I Have 3 browsers set up on my dev machine - IE6, firefox3, and Chrome.

    I get identical results on each of the browsers. Works fine when I open the file with any of the browsers but doesn't seem to see the javascript function when I serve up the file using "localhost" or the remote server.

    I've used "Firebug" to try and isolate what's happening. I can set breakpoints and see all values on the "opened files", but when I use Firebug on the served files I get nothing except "undefined" when I try to set a breakpoint on the "Alert" line.

    I'm sure I'm missing something very basic. I'll try rebooting my system next - just a shot in the dark.

    Thanks for the reply,
    Dick
     
    dtolpin, May 29, 2009 IP
  4. dtolpin

    dtolpin Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you all for reading my post. I just rebooted my computer and the problem went away. I don't have a clue what happened, but I learned that I should try reboots BEFORE bringing my problems to the forum.

    Thanks GreatMetro for your response. Just replying to you helped me think about rebooting my system.

    Thanks again,
    Dick Tolpin
     
    dtolpin, May 29, 2009 IP