Problem with Loading JavaScript

Hello guys,

I have a problem with loading JavaScript in Web Browser in general.
I am using Brackets and WebStorm IDE and I have tried including script src files
to external js files in an HTML file . I tried to draw something on canvas , but without success-the js files don’t seem to work and there are unresolved references.I also tried to install NodeJS to the folder directory and set it as a path.Even when I add a script tag in the HTML ,code inside it won’t compile at all.

Any help?

Thanks :slight_smile:

You need to show us the code that isn’t working, as well as any error messages (open the browser’s developer tools and look for errors in the console)

Here are the errors in the developer

and here is the code

if (typeof(window)=="undefined"){
    var window = {}   
}

function various(){
    console.log("Choose a number to enter");
}

window.addEventListener('load', various, false);

function someFunc(){
    document.write("Some stuff to be seen by viewers");
}

// ..... or 
window.addEventListener('DOMContentLoaded', yourFunction, false);

window.onload=someFunc(); 

I also made a canvas but i deleted it ,because I have to show the HTML file.
Basically there is no reference to document, console and window.

All the code please, you’re not showing the HTML that actually brings in that JS

Also copy paste the error text please, we don’t have special kinds of eyes that make it possible to make almost unreadable text in photographs readable!

Sorry for the unreadable image.

I hope it is clear now.

The HTML file

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>GETTING STARTED WITH BRACKETS</title>
    <meta name="description" content="An interactive getting started guide for Brackets.">
    <link rel="stylesheet" href="main.css">
    
    <script type ="text/javascript" src="Game.js"></script>
   
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body style=-"overflow: hidden">
    
    <h1>GETTING STARTED WITH BRACKETS</h1>
    <h2>This is your guide!</h2>
    
    <!--
        MADE WITH <3 AND JAVASCRIPT
    -->
    
    <p>
        Welcome to Brackets, a modern open-source code editor that understands web design. It's a lightweight,
        yet powerful, code editor that blends visual tools into the editor so you get the right amount of help
        when you want it.
    </p>
    
    <!--
        WHAT IS BRACKETS?
    -->
    <canvas width="500" height="400" id="myCanvas">
    </canvas>
        
    <script>
        
        var c = document.getelElementbyId("myCanvas");  
        var ctx = c.getContext("2d");
        ctx.beginPath();
        ctx.arc(100,50,0,2.5*Math.PI);
        ctx.stroke();
        
        document.write("Ypu are bastard !")
        
    </script>
    
    <samp>
        Once you're ready to get out of this sample project and edit your own code, you can use the dropdown
        in the left sidebar to switch folders. Right now, the dropdown says "Getting Started" - that's the
        folder containing the file you're looking at right now. Click on the dropdown and choose "Open Folder…"
        to open your own folder.
        You can also use the dropdown later to switch back to folders you've opened previously, including this
        sample project.
    </samp>
    
    <!--
        THE RELATIONSHIP BETWEEN HTML, CSS AND JAVASCRIPT
    -->
    <h3>Quick Edit for CSS and JavaScript</h3>
    <p>
        No more switching between documents and losing your context. When editing HTML, use the
        <kbd>Cmd/Ctrl + E</kbd> shortcut to open a quick inline editor that displays all the related CSS.
        Make a tweak to your CSS, hit <kbd>ESC</kbd> and you're back to editing HTML, or just leave the
        CSS rules open and they'll become part of your HTML editor. If you hit <kbd>ESC</kbd> outside of
        a quick inline editor, they'll all collapse. Quick Edit will also find rules defined in LESS and
        SCSS files, including nested rules.
    </p>
    
    <samp>
        Want to see it in action? Place your cursor on the <!-- <samp> --> tag above and press
        <kbd>Cmd/Ctrl + E</kbd>. You should see a CSS quick editor appear above, showing the CSS rule that
        applies to it. Quick Edit works in class and id attributes as well. You can use it with your
        LESS and SCSS files also.
        
        You can create new rules the same way. Click in one of the <!-- <p> --> tags above and press
        <kbd>Cmd/Ctrl + E</kbd>. There are no rules for it right now, but you can click the New Rule
        button to add a new rule for <!-- <p> -->.
    </samp>
    
    <a href="screenshots/quick-edit.png">
        <img alt="A screenshot showing CSS Quick Edit" src="screenshots/quick-edit.png" />
    </a>
    
    <p>
        You can use the same shortcut to edit other things as well - like functions in JavaScript,
        colors, and animation timing functions - and we're adding more and more all the time.
    </p>
    <p>
        For now inline editors cannot be nested, so you can only use Quick Edit while the cursor
        is in a "full size" editor.
    </p>
    
    <!--
        LIVE PREVIEW
    -->
    <h3>Preview HTML and CSS changes live in the browser</h3>
    <p>
        You know that "save/reload dance" we've been doing for years? The one where you make changes in
        your editor, hit save, switch to the browser and then refresh to finally see the result?
        With Brackets, you don't have to do that dance.
    </p>
    <p>
        Brackets will open a <em>live connection</em> to your local browser and push HTML and CSS updates as you
        type! You might already be doing something like this today with browser-based tools, but with Brackets
        there is no need to copy and paste the final code back into the editor. Your code runs in the
        browser, but lives in your editor!
    </p>
    
    <h3>Live Highlight HTML elements and CSS rules</h3>
    <p>
        Brackets makes it easy to see how your changes in HTML and CSS will affect the page. When your cursor
        is on a CSS rule, Brackets will highlight all affected elements in the browser. Similarly, when editing
        an HTML file, Brackets will highlight the corresponding HTML elements in the browser.
    </p>
    
    <samp>
        If you have Google Chrome installed, you can try this out yourself. Click on the lightning bolt
        icon in the top right corner of your Brackets window or hit <kbd>Cmd/Ctrl + Alt + P</kbd>. When
        Live Preview is enabled on an HTML document, all linked CSS documents can be edited in real-time.
        The icon will change from gray to gold when Brackets establishes a connection to your browser.
        
        Now, place your cursor on the <!-- <img> --> tag above. Notice the blue highlight that appears
        around the image in Chrome. Next, use <kbd>Cmd/Ctrl + E</kbd> to open up the defined CSS rules.
        Try changing the size of the border from 10px to 20px or change the background
        color from "transparent" to "hotpink". If you have Brackets and your browser running side-by-side, you
        will see your changes instantly reflected in your browser. Cool, right?
    </samp>
    
    <p class="note">
        Today, Brackets only supports Live Preview for HTML and CSS. However, in the current version, changes to
        JavaScript files are automatically reloaded when you save. We are currently working on Live Preview
        support for JavaScript. Live previews are also only possible with Google Chrome, but we hope
        to bring this functionality to all major browsers in the future.
    </p>
    
    <h3>Quick View</h3>
    <p>
        For those of us who haven't yet memorized the color equivalents for HEX or RGB values, Brackets makes
        it quick and easy to see exactly what color is being used. In either CSS or HTML, simply hover over any
        color value or gradient and Brackets will display a preview of that color/gradient automatically. The
        same goes for images: simply hover over the image link in the Brackets editor and it will display a
        thumbnail preview of that image.
    </p>
    
    <samp>
        To try out Quick View for yourself, place your cursor on the <!-- <body> --> tag at the top of this
        document and press <kbd>Cmd/Ctrl + E</kbd> to open a CSS quick editor. Now simply hover over any of the
        color values within the CSS. You can also see it in action on gradients by opening a CSS quick editor
        on the <!-- <html> --> tag and hovering over any of the background image values. To try out the image
        preview, place your cursor over the screenshot image included earlier in this document.
    </samp>
    
    <h3>Need something else? Try an extension!</h3>
    <p>
        In addition to all the goodness that's built into Brackets, our large and growing community of
        extension developers has built hundreds of extensions that add useful functionality. If there's
        something you need that Brackets doesn't offer, more than likely someone has built an extension for
        it. To browse or search the list of available extensions, choose <strong>File > Extension
        Manager…</strong> and click on the "Available" tab. When you find an extension you want, just click
        the "Install" button next to it.
    </p>
    
    <!--
        LET US KNOW WHAT YOU THINK
    -->
    <h2>Get involved</h2>
    <p>
        Brackets is an open-source project. Web developers from around the world are contributing to build
        a better code editor. Many more are building extensions that expand the capabilities of Brackets.
        Let us know what you think, share your ideas or contribute directly to the project.
    </p>
    <ul>
        <li><a href="http://brackets.io">Brackets.io</a></li>
        <li><a href="http://blog.brackets.io">Brackets Team Blog</a></li>
        <li><a href="https://github.com/adobe/brackets">Brackets on GitHub</a></li>
        <li><a href="https://brackets-registry.aboutweb.com">Brackets Extension Registry</a></li>
        <li><a href="https://github.com/adobe/brackets/wiki">Brackets Wiki</a></li>
        <li><a href="https://groups.google.com/forum/#!forum/brackets-dev">Brackets Developer Mailing List</a></li>
        <li><a href="https://twitter.com/brackets">@brackets on Twitter</a></li>
        <li>Chat with Brackets developers on IRC in <a href="http://webchat.freenode.net/?channels=brackets&uio=d4">#brackets on Freenode</a></li>
    </ul>
    
</body>

The Game.js file is the JS file i sent you earlier.

  1. to import bootstrap cdn copy all three links here and paste it into your html head. It needs the jquery link also.
    Download · Bootstrap

  2. your call var c = document.get**el**ElementbyId("myCanvas"); has a typo.

  3. Chrome specifically blocks local file access this way for security reasons.
    Here’s a workaround to enable the flag in Chrome (and open your system up to vulnerabilities):

c:\Program Files (x86)\google\chrome\Application\chrome.exe --allow-file-access-from-files

Also try to put the file into your project folder as chrome does not allow external resources easily.

  1. your Code has a lot of typos. Be more accurate.