If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Works within <script> tag, but not in external JS file

Hi,

I have a script that I'm trying to run from a canvas element on my html page. When I place it within a <script> tag in the body of the html page it draws on the canvas just fine. But when I link it to the external script.js file, nothing is drawn. I know that the script.js file is linking correctly, because the prompt comes up in both cases, but no drawing in the latter. I'm thinking that line 2 is not getting the correct element for some reason. Any suggestions?

you need to update your browser, that screenshot looks to be out of date...

No it isn't - that's the way the prompt dialog currently looks in the latest version of Opera.

In Chrome and Firefox the message next to the checkbox is different - asking if you want to disable all future dialogs (alert/confirm/prompt) instead of disabling JavaScript completely. That makes the different browsers useful for two different types of debugging of scripts that use these debugging calls depending on whether you want the ability to just stop the JavaScript completely (using Opera with such calls to debug why your code is stucjk in an infinite loop) or to debug values in a loop that runs a large but finite number of times (using Chrome or Firefox to view the first so many values and then disable the display of the dialogs for the rest of the iterations of the loop). Which browser you'd choose to use the debugging dialogs with depends on what sort of JavaScript problem you are trying to debug.

No it isn't - that's the way the prompt dialog currently looks in the latest version of Opera.

first off, why choose the least popular browser to make a point, seems misleading.

second, and more importantly, as i said, your screenshot is old. i guess you don't actually use opera or you would have noticed by now. Dumb options like killing JavaScript have been removed. I cannot find a single current browser that behaves as you describe.

while i agree that prompt() is not the best option for gathering input, let's sell our opinion with facts instead of carefully-selected worst-case-scenarios that aren't even valid anymore:

the "don't ask again" option in chrome is reason enough not to rely on the feature. The poorly-worded "OK/CANCEL" button labels make for less helpful UI than "Save Name / Cancel Name Change" would. Async programming will result in applications that are easier to test, deploy, and maintain. In short, there's plenty of good reasons not to use prompt(), let's not oversell our case with mis-information.

Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

fthe "don't ask again" option in chrome is reason enough not to rely on the feature. The poorly-worded "OK/CANCEL" button labels make for less helpful UI than "Save Name / Cancel Name Change" would. Async programming will result in applications that are easier to test, deploy, and maintain. In short, there's plenty of good reasons not to use prompt(), let's not oversell our case with mis-information.

There has been no reason to use them for anything except debugging since Netscape 4 died. Since the latest version of Firefox now has a debugger built in (the same as all other browsers have for some time now) there is no reason to use them even for debugging. This means that they are effectively obsolete and ought not to be used any more for any purpose (except by newbies to JavaScript who are copying (or being taught how to) code for Netscape 4 and earlier browsers).

I use Opera all the time and have the updates turned on. My browser assures me that the 12.16 version that I am running (which displays the dialog almost exactly as I have shown) is the latest version.

Its getting really tempting to install override functions as a userscript into the browser so that so that the browser will ignore such antiquated code. Particularly since their main use seems to be the annoying are you sure you want to leave confirm boxes.