Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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. 🙂
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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"
Copy link to clipboard
Copied
Try the following:
<!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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now