Results 1 to 13 of 13

Thread: [RESOLVED] Help cannot run javascript

  1. #1

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Resolved [RESOLVED] Help cannot run javascript

    does anyone know why i cannot run javascripts buy double clicking on them all I get is this error message. anyone have a clue, Ps I am using Vista if that helps.

    Script: C:\Users\Ben\Desktop\Untitled1.js
    Line: 1
    Char: 1
    Error: Object expected
    Code: 800A138F
    Source: Microsoft JScript runtime error

    Bascily it will not allow me to run any code even a simple alert messagebox any help will be helpfull thanks.

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Help cannot run javascript

    What is the code you currently have in the *.js file?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Help cannot run javascript

    JavaScript is not something that can be run by the operating system. JavaScript is run by a JavaScript engine, and these are most often found within browsers. You'll need to create an HTML file that embeds your JavaScript file in order to "run" it using your browser. The quickest and dirtiest example would be:

    myJavaScript.htm:
    HTML Code:
    <script language="javascript" type="text/javascript" src="myJavaScriptFile.js"></script>
    of course, you'd need to make sure the "src" attribute of the <script> tag was the path to your JavaScript file.

    oh, and in case you didn't know -- an HTML file is simply a text file with the extension "HTM" or "HTML"; there is no magic to creating one.

  4. #4

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Re: Help cannot run javascript

    The code i am trying to run is

    Code:
    alert("Hello, World!");
    I also downloaded two java script editors and both of them can not run the code well it won;t run any code bascily.

    I am i missing something on my OS, I tryed vbscript and they work fine it just the javascripts

    any ideas

  5. #5
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Help cannot run javascript

    Quote Originally Posted by BenJones View Post
    I am i missing something on my OS, I tryed vbscript and they work fine it just the javascripts
    I'm not sure how Microsoft JScript works but this is how you would normally get the code to work.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
      <script language="JavaScript" src="Untitled-2.js" type="text/javascript"></script>
    </head>
    </html>
    The javascript link would normally go in the page header as see above (however, you can place it anywhere between the header or body). Although, since, I am using Dream Weaver I don't know if other programs would be any different but I doubt it.
    Last edited by Nightwalker83; Mar 18th, 2010 at 04:48 AM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  6. #6
    Hyperactive Member coothead's Avatar
    Join Date
    Oct 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    285

    Re: Help cannot run javascript

    Hi there BenJones,

    this is the code...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    
    <title>hello world</title>
    
    <script type="text/javascript">
        alert('Hello, World')
    </script>
    
    </head>
    <body>
    
    <div></div>
    
    </body>
    </html>
    
    This is the method...
    1. Open NotePad.
    2. Copy & Paste the code into NotePad.
    3. How to Copy & Paste

      1. With your mouse, place cursor at the beginning of the code in the textarea.
      2. Hold the left-mouse down and then drag the mouse down to the bottom of the textarea.
      3. This has the effect of highlighting the code.
      4. Release the left-mouse.
      5. Right-mouse click will bring up a small dialog box.
      6. Scroll down the dialog box and click Copy.
      7. With your mouse, place cursor over NotePad.
      8. Right-mouse click will bring up a small dialog box.
      9. Scroll down the dialog box and click Paste.
    4. Click File.
    5. Click Save As....
    6. This will bring up a dialog box similar to this...


      *
    7. Type in the file name with the extension .html.
    8. Select the desired 'Directory' in Save in: .
    9. Click Save.
    10. Go to your selected 'Directory' to test your file.
    11. Double clicking the some_name.html file will open it in your default browser
    12. Finally have a beer.


    ~ the original bald headed old fart ~

  7. #7
    Hyperactive Member coothead's Avatar
    Join Date
    Oct 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    285

    Re: Help cannot run javascript

    Quote Originally Posted by Nightwalker83 View Post
    I am yet to see a forum without a quote button! If there is I should join it.
    Try this one...


    ~ the original bald headed old fart ~

  8. #8

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Re: Help cannot run javascript

    hi coothead that seems to work. But what I am not sure of is why if i try any code in a javascript editor it code just errors up, the editors I am using are also both professional editors that are ment to run javascript, VBscript works perfect. I just do not understand unless i need to enable something on my system.

    Thanks for all your help to.

  9. #9
    Hyperactive Member coothead's Avatar
    Join Date
    Oct 2007
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    285

    Re: Help cannot run javascript

    Hi there Ben,

    Sorry, but I am unable to help you on those issues.

    I use Notepad for all my coding requirements and have no experience of "professional editors".


    ~ the original bald headed old fart ~

  10. #10
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Help cannot run javascript

    What program(s) are you using, Ben? It sounds like you're inputting Javascript directly into an IDE and expecting it to run independently... When you do this with VBScript, it works fine because that can be run by the [Windows] OS. But, as kows said, "JavaScript is not something that can be run by the operating system." It needs to run in the proper context (usually a browser) or else it just won't work.

  11. #11
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Help cannot run javascript

    Quote Originally Posted by coothead View Post
    Well, at least you've listed it in case I ever need or want it.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Help cannot run javascript

    JavaScript is just a language. You need to specify which actual environment you are working in. Usually this is a web browser but JS can be applied in other areas too.

    JScript is a Microsoft variation of JavaScript which is used by Windows Script Host. You can write WSH scripts in JScript or VBScript. The default handler for .js files is often WSH if it is enabled.

  13. #13

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Re: Help cannot run javascript

    I sorted the problum out now I needed to use WScript.Echo my scripts work fine now Thanks for all the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width