Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9
  1. #1
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    I have a file containing several functions of the VBScript variety. I'd like to have one for the Javascript functions, but I can't figure out how to set up the page and I can't find the reference in the JScript book I bought (JavaScript Bible).

    References, code, tomatoes?
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  2.  

  3. #2
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Put the functions in filename.js file.

    then put the following in the head tag of your page:
    Code:
    <script language="JavaScript" src="filename.js" type="text/javascript"></script>
    There and Back Again :Ogre:

  4. #3
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    In a recent reply, someone mentioned that ~~~~.inc was observable to anyone who really wanted to find it. Does the same thing apply to the ~~~.js extension?

    I
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  5. #4
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    The above mentioned tip was regarding server side languages, like ASP and PHP.

    there is no parse-able code in javascript, it will go to client browser anyway. You need .js extension if you want to load into your page using <script> tag.
    There and Back Again :Ogre:

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Right, there's no point in renaming Javascript file extensions as they're sent to the client as is and not compiled/executed on the server (although there is such a thing as server-side Javascript).
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    filename.js
    Code:
    <SCRIPT language=javascript type=text/javascript>  
     function picktable(IndexNum)
     {
    
    ...
    
    }
    TotalSQL.asp
    Code:
    <HTML>
    <HEAD>
    <script language="JavaScript" src="filename.js" type="text/javascript"></script>
    </HEAD>
    <BODY>
    
    
    .....
    
       
       strTemp1="'picktable(" & chr(1) & ")'"
       strTemp2 = " bgColor='#33FF66'" 
       strTemp0 = strTemp0 & " onClick=" & strTemp1 & strTemp2
       TableHTML=  "</tr><tr " & strtemp0 & "><td>"
       TableHTML = TableHTML & Rst_Demo.getstring(,, "</td><td>", "</td></tr><TR" & strTemp0 & "><TD>", "no data")
       TableHTML = TableHTML &  "</td></tr></table>"  
    
    ....
    Now, irrespective of the squirelliness of above code, when picktable is physically in the file of TotalSQL.asp it works perfectly.

    When I move it to filename.js, I get a syntax error and then mis-match error.

    I tried putting in the absolute address of the file "C:....." but it made no difference.

    When I put the declaration in the body (where it's used) the syntax error went away, but the type mis-match stays. I'm accessing the parent.frames property. That's probably the problem.
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  8. #7
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    .js file doesn't need to contain <script> tag, try removing that.

    Also are you trying to put some ASP code in .js file?
    There and Back Again :Ogre:

  9. #8
    Senior Member
    Join Date
    Mar 2002
    Location
    Alabama sans the damn flag
    Posts
    263
    Member #
    38
    well, I don't think so ... correction, I DIDN'T think so, but I could well be. Since that is the case, I think I'll just go on the way I was and get some more experience with the Jscript stuff before trying to clean it up.

    Lord knows, I'll be 4 months on this stupid project anyway.
    DerFarm
    I talk to squirrels.
    Squirrels Answer.

  10. #9
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Originally posted by DerFarm
    well, I don't think so ... correction, I DIDN'T think so, but I could well be. Since that is the case, I think I'll just go on the way I was and get some more experience with the Jscript stuff before trying to clean it up.

    Lord knows, I'll be 4 months on this stupid project anyway.
    Ah, but with WDF on the case you'll be done on 4 days

    Anyway, in the .js file, you can only use 100% pure Javascript (i.e., not MS's JScript or anything like that). ASP won't get parsed. Also don't include the red parts in this example:
    Code:
    <script type="text/javascript">
    <!--
    var something = 1;
    // -->
    </script>
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:30 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com