Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Javascript Issues

Featured Replies

I know that this is probably a problem with a very simple solution, but I've been unable to find one.

I have a fair amount of experience building static sites in XHTML and CSS, and am attempting to move into dynamic sites, beginning by learning Javascript.

Whereas with a static site you can simply run the file from the hard drive of your development computer, if I do so with a file containing Javascript, the HTML displays, and the Javascript is totally inactive. Adding a <noscript> line to check if that is the problem failed to resolve it, as every setting is set to allow Javascript to run, in all 3 browsers I've tried (IE, Firefox, Opera). The only exception is IE, which throws up a security warning at first, but if you allow it, the <noscript> line disappears, but the script is still inactive.

 

While I do have access to online servers, it would be a lot easier and faster, certainly in the learning stage, if I can run the files for testing through the file:///C:/~ route.

 

Any suggestions on how to resolve this?

 

Gal

  • Author

Update: adding MooTools 1.2 as an external .js solves this issue, but I'm still wondering if there's any other solution to this problem, and if it's one that anybody else has run into.

 

Extra info: this problem has occurred with me on both XP Pro and Vista Home Premium (different computers)

 

Gal

Can't say it's something I've experienced, but I'd recommend setting up a server on your computer for testing locally.

 

Things like Xampp contain everything you need, like php, mysql etc, and can be installed easily.

 

Makes it a lot easier, and it also means you can run php files locally too :)

  • Author

Yeah I am intending to, I simply haven't had a chance around other work commitments. I have the installer for Apache 2.2.11, hopefully installing that and configuring it should help :unknw:

That's the beauty of Xampp mate, it doesn't require any configuring really. It's pretty much "plug n play"

You don't need to set up a local server for testing with JavaScript as it runs in the browser/clientside.

The fact that the Javascript didn't do anything suggests a fault in the Javascript itself.

Have a look at installing the Firebug extension for Firefox to debug any future Javascript problems.

You don't need to set up a local server for testing with JavaScript as it runs in the browser/clientside.

 

I know that lol, was just a general suggestion :pp

I know that lol, was just a general suggestion :pp

Not aimed at your good self Scott but the OP :)

Not aimed at your good self Scott but the OP :)

 

Ah OK :)

 

Beers are on me in the bar then good sir :)

  • Author

I'm well aware that a server shouldn't be necessary to run Javascript, but I'm also about to start learning PHP and MySQL, which does require a server.

I will get the Firefox extension and try it, but that won't do a lot for IE or Opera. Adding the MooTools JS framework as an external .js seems to get the code working, so I'll run with that as a solution for the moment unless someone comes up with another.

 

XAMPP is now ready to be installed as soon as I get back to my working computer, should make life a bit easier :good:

XAMPP is now ready to be installed as soon as I get back to my working computer, should make life a bit easier

 

You'd think wouldn't you :pp xampp is great, but just beware that certain situations you may need to do some alterations to the config, it's easy peasy though and plenty of help on line.

 

Also it can be quirky with software, on my other machine installing avg effectively broke my xampp installation (idk why?) and then i recently installed aptana, and now i can't use http://localhost/ ): (http://127.0.0.1/ still works though :p). I however have reverted back to notepad++, aptana's long gone, but my problem remains ):

 

Just pointing out that you may have to get your hands dirty, and receive a few headaches along the way, but that's the fun in learning (actually i found messing with the config files after following online instructions gave me a better understanding of it).

 

Oh and P.S chrome could never access localhost for me, but using 127.0.0.1 always worked :pp (dunno if that was just my pc though, i seem to have a very moody pc :()

I'm well aware that a server shouldn't be necessary to run Javascript, but I'm also about to start learning PHP and MySQL, which does require a server.

 

The reason I mentioned that you don't need a server set up to run javascript is because your first post suggested you thought that to be the case. You didn't mention PHP.

I have a fair amount of experience building static sites in XHTML and CSS, and am attempting to move into dynamic sites, beginning by learning Javascript.

Whereas with a static site you can simply run the file from the hard drive of your development computer, if I do so with a file containing Javascript, the HTML displays, and the Javascript is totally inactive.

 

Gal

Sorry I misunderstood

  • Author

Notepad++ is my favoured editor as well. I've found it immeasurably helpful, and I totally agree with you about looking online for info and instructions then trying them.

 

Having looked at various other software packages, including Dreamweaver, I decided I prefer the Notepad++ interface, and the fact that it doesn't cost nearly £300!

 

The reason I mentioned that you don't need a server set up to run javascript is because your first post suggested you thought that to be the case.

 

Reason I mentioned that was because I have no problems running online pages containing Javascript, although admittedly I haven't actually tried hosting a page of my own script to try and run it.

  • Author

OK, help is becoming even more necessary. Adding MooTools as an external .js appeared to solve the issue, but today that has no effect. Even the most simple example (copied and pasted directly from w3schools.com) simply gives a blank page.

 

One of the example scripts that I copied and pasted, then saved as a .html is below.

 

<html>

<head>

<title>JavaScript Basics</title>

<noscript>

You have JavaScript disabled

</noscript>

<script type="text/javascript" src="mootools-1.2-core.js" />

</head>

 

<body>

<script type="text/javascript">

{

document.write("<h1>This is a header</h1>");

document.write("<p>This is a paragraph</p>");

document.write("<p>This is another paragraph</p>");

}

</script>

</body>

</html>

 

Now can somebody please tell me, am I just being thick as the proverbial plank, and what I can do to get this to display anything other than a totally blank page. Even the <noscript> text fails to appear, so I know that JS is active, but why doesn't it DO anything?

 

Please answer before my computer gets a flying lesson

You can't close a script tag that way. You have to use

 

<script type="text/javascript" src="mootools-1.2-core.js"></script>

 

Not sure whether it's your only problem, but it's definitely a show-stopper.

  • Author

OK, changing that appears to have done the trick, so to answer my own question, yes I was being as thick as the proverbial plank. Many thanks

<script> isn't a self closing tag - (as above)

xampp/any server software will NEVER fix any javascript errors... Firebug will give you the answer ;)

 

I don't see the need for the curlies inside your script tags within your body tags?

  • Author
<script> isn't a self closing tag - (as above)

xampp/any server software will NEVER fix any javascript errors... Firebug will give you the answer ;)

 

I don't see the need for the curlies inside your script tags within your body tags?

 

Time for me to check out Firebug then! I wasn't expecting server software to fix the problems, just been searching for a solution to the issue, and I finally seem to have found one.

 

There isnt any need for the curlies, it's just that the coding came from an example showing Javascript statement blocks :unsure:

Glad my tip was helpful. Good luck with Firebug - it's powerful but not particularly intuitive... :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.