Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

console.log("Hello World");

New Here ,
Jun 29, 2021 Jun 29, 2021

I tried to write the script tag console.log ("Hello World") in DreamWeaver CC 2021, but didn't work. Appeared the follow message:  ERROR: Unexpected console statement. [no-console]. Why is this happened?

4.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 29, 2021 Jun 29, 2021

console.log() is what is output to the 'browser' console and can be viewed by using the browser devtools or does DW have its own terminal window where you are trying to output javascript code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 29, 2021 Jun 29, 2021

os good_

 

I think so. But I Am begginer in JavaScript, and all the tutorials that I've read teach that I must to write this tag all the time, in the code. How must I run the code, in Preview in Browser?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2021 Jun 29, 2021

Dreamweaver is first & foremost an HTML code editor. 

Start with an HTML document.  Go to File > New > HTML > hit the Create button.

Add JavaScript between the <script> tags inside your HTML document.

Use Ctrl/Cmd + S to save.

Preview in your favorite browser (F12).

 

Example:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Test</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<p>Lorem ipsum dolor...</p>
<hr>
<script>
 alert( 'Hello, world!' );
</script>
</body>
</html>

 

Hope that helps.  🙂

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 29, 2021 Jun 29, 2021
quote

os good_

 

I think so. But I Am begginer in JavaScript, and all the tutorials that I've read teach that I must to write this tag all the time, in the code. How must I run the code, in Preview in Browser?


By @carlos humbertoa71580393

 

You write your javascript in the Dreamweaver editor between blocks of <script></script> tags. Example code below will output 'Apple' to the page and 'Apple' in the browsers web-console using console.log()

 

View the page in a browser and locate the web-development tools in the browser you are running and look for 'Web Console'. You should see 'Apple' in the console.

 

Example code:

 

<div class="output"></div>

 

<script>

const fruit = "Apple";

document.querySelector('.output').innerHTML = `<h1>${fruit}</h1>`;

console.log(fruit);

</script>

 

console.log() is used to check what is being output so you have a better understanding of what is going on and yes if you are writting javascript then console.log() is going to be very useful.

 

Below is a beginner tutorial about the web console:

https://www.youtube.com/watch?v=73oP9wbWsPY 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2021 Jun 29, 2021

yes you're right, the console object use to work in Dreamweaver, but as soon as the chrome engine become editable in live view, I think that the team remove this feature.

it was displaying the output in  the result panel (Site Report) as you can see in this tutorial

https://www.linkedin.com/learning/l-essentiel-de-dreamweaver-cc-2013-5-flux-de-donnees-et-interactiv...

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 29, 2021 Jun 29, 2021

Thank you, osgood_ ! Thank you, Nancy OShea! Thank you, Birnou! The Adobe's coder said to me, in the chat, that console is a global, not a universal, 'cause this doesn't works in DreamWeaver.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2021 Jun 29, 2021
LATEST

it makes sense. Since I don't use the Live View window anymore, I have no other solution than to use a real browser to use the console.log() function.

 

Anyway, if the Linting causes you trouble, you can deactivate this Error, from the JSLint JSON Propeties file. For that go to your site definition, you will find on the advanced parmaters, the JS Lint category.

 

From there, you will be able to Edit the configuration file, and on the rules definition, modify the

"no-console": "error" definition to

"no-console": "off"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2021 Jun 29, 2021

Try the following:

 
HTML:
<!doctype html>
<html>

<head>
    <meta name="ac:base" content="/test-php">
    <base href="/test-php/">
    <meta charset="UTF-8">
    <title>Untitled Document</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>

<body id="index">


    <script src="myjs.js"></script>
</body>

</html>

 

The Javascript file called `myjs.js`:

console.log("Hello World")

 

Then view the file with the console tab selected and see

BenPleysier_0-1625004478007.png

 

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines