SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Ann Arbor, MI
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Browser won't recognize script...

    All,

    Here's the script I'm having trouble with:
    Code:
    <html>
    <head>
        <title>Join Game: <%= game.getGameName() %></title>
        <META HTTP-EQUIV="Expires" CONTENT="-1">
        <link href="seiv.css" rel="STYLESHEET" type="text/css">
        <base target="_top">
        <script type="text/javascript">
            function joinIn() {
                parent.menu.document.pic18.src = parent.menu.GreyImg[18].src
                parent.menu.document.pic19.src = parent.menu.OffImg[19].src
                /*var pw = document.gamepw.value
                var name = document.empname.value
          */    }
       </script>
    </head>
    <body bgcolor="#000000" text="#0099FF">
    
    <H2>Join Game:  <%= game.getGameName() %></H2>
    <FORM name="stuff" METHOD=POST ACTION='javascript:joinGame()'>
    <TABLE>
    <TR><TD>Empire password:</TD>
        <TD><INPUT TYPE=TEXT NAME='gamepw'></TD></TR>
    <TR><TD>Empire name:</TD>
        <TD><INPUT TYPE=TEXT NAME='empname'></TD></TR>
    </TABLE>
    <INPUT TYPE=HIDDEN NAME='<%= GamePlayer.PARAMETER_COMMAND %>' VALUE='<%= GamePlayer.COMMAND_JOIN %>'>
    <INPUT TYPE=HIDDEN NAME='<%= GamePlayer.PARAMETER_GAME_ID %>' VALUE='<%= gameId %>'>
    <INPUT TYPE=HIDDEN NAME='<%= GamePlayer.PARAMETER_OK %>' VALUE='<%= thisURL %>'>
    <!--INPUT TYPE=image src="img/joingame.gif"-->
    <a href="javascript:joinIn()"><img src="img/joingame.gif"></a>
    </FORM><P>
    The link at the bottom is supposed to call the joinIn function, which causes a number of things to happen.

    The error I get from Netscape is "joinIn is not defined." But... as far as I can tell, I've defined it correctly... to the point where the same script, cut and pasted, works on a different page (to which it applies). Can anyone figure what I'm doing wrong?

    Thanks in advance,

    LL

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does it work in IE? And do you have a </body></html>?

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Ann Arbor, MI
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, and yes, in that order.

    IE returns "object expected" at line 1, character 1. No idea what that might be about though.

    LL

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Ann Arbor, MI
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, an extra oddity to report: the js errors on both platforms are not coming up for the file name (i.e. /test/joingame.jsp?1n803ki) but for the directory (/test/)... which might explain why it's not thinking the function is defined, but adds a different mystery.

    LL

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Ann Arbor, MI
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The story so far:

    After doing some more checking, it appears the problem is not the script itself, but the way in which I'm getting the page to display. The pages are, for the most part, being called by:

    parent.main.document.location.href = "whatever.jsp?foo=" + bar

    The script works when I simply type the URL into the browser; when called by the above, though, the scripts inside the called page don't work.

    So, the question is: is there any way to display a page other than using document.location.href= ? (Besides, the obvious, using <a href=...>, which I can't use because the called page varies while the menu page where the link is is static.

    LL

  6. #6
    The short answer is yes... Herbster's Avatar
    Join Date
    Oct 2001
    Location
    Bay City, Oregon
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "parent.main.document.location.href = "whatever.jsp?foo=" + bar

    The script works when I simply type the URL into the browser; when called by the above, though, the scripts inside the called page don't work."

    OK. Since it works when you type it in, and it doesn't work when you call it from code, I would temporarily try something like:

    alert("whatever.jsp?foo=" + bar)

    ...to see what the browser thinks it is processing.

    Unless, of course, I've completely missed the point - lol.


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
  •