>>This must be super newbie question.
>>
>>If I create a javascript function in my page javascript, like the following:
>>
>>function TestMsg()
>>{
>> alert('Test Message');
>>}
>>
>>everything works. In the javascript, before the above function is written, I can call:
>>
>>TestMsg();
>>
>>and Alert shows the message.
>>
>>But if I move the above function to an external .js file (e.g. dmitry.js) as follows:
>>
>><script type="text/javascript">
>>function TestMsg() {
>> alert('test message');
>>}
>></script>
>>
>>I check in the Chrome that the file dmitry.js is loaded. But when I call TestMsg(); in the javascript, nothing alerts.
>>
>>What am I missing?
>
>Unless you've swapped the code snippets above then, in the external file, the function should *not* be enclosed in a 'script' tag. i.e. this should work:
<!DOCTYPE html>
><html xmlns="http://www.w3.org/1999/xhtml">
><head>
> <title></title>
></head>
><body>
> <script type="text/javascript" src="dmitry.js"></script>
> <button onclick="TestMsg()">Click me</button>
></body>
></html>
and Dmitry.js:
function TestMsg() {
> alert('test message');
>}
Thank you very much. My mistake.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham