<html>
<head>
<title>My HTML</title>
<script type="text/javascript"></script>
document.write("Hello World");
</head>
<body>
</body>
</html>
How Do I remove the document.write part of the output? My chrome output is document.write("Hello World");
I just want to output Hello World on Chrome.
You need to move the closing script tag to be after the document.write("Hello World") so that the document.write() is encased within the script tag. e.g.
<html>
<head>
<title>My HTML</title>
<script type="text/javascript">
document.write("Hello World");
</script>
</head>
<body>
</body>
</html>
Related
i have my react code in plain HTML
<!Doctype html>
<html>
<head>
<meta charset="uttf-8">
<title>React! React! React!</title>
<script src="https://unpkg.com/react#16/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom#16/umd/react-dom.production.min.js" crossorigin></script>
<script src="https://unpkg.com/babel-standalone#6.15.0/babel.min.js"></script>
</head>
<body>
<script>
ReactDOM.render(
<h1>Sherlock Holmes</h1>,
document.body
);
</script>
</body>
</html>
but he not work, after run this index.html in Chrome i have only blank white page,
can someone explain me what i am doing wrong?
i use vscode
To make this work, use the development version, not the production version of the react and react-dom files. Also note that you need to specify the type of your script as "text/babel" or babel won't parse it.
Check out the code below:
<html>
<head>
<script src="https://unpkg.com/babel-standalone#6/babel.min.js"></script>
<script src="https://unpkg.com/react#16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom#16/umd/react-dom.development.js"></script>
</head>
</head>
<body>
<script type="text/babel"> /* notice type="text/babel"*/
ReactDOM.render(
<h1>Sherlock Holmes</h1>,
document.body
);
</script>
</body>
</html>
RESULT:
I did react for the first time and it edited your code like that. I guess the two scripts I added are not needed, but just try it. As I understood you have to set an section to place the text. These two links could help too.
Where to place line of code in html for ReactDOM.render?
https://www.w3schools.com/react/react_render.asp
My Code:
<!Doctype html>
<html>
<head>
<meta charset="uttf-8">
<title>React! React! React!</title>
<link rel="stylesheet" href="lib/style.css" />
</head>
<body>
<section id="entry-point"></section>
<script src="https://unpkg.com/react#16/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom#16/umd/react-dom.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react#15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom#15/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone#6.15.0/babel.min.js"></script>
<script type="text/javascript">
var h = React.createElement('p', null, 'Sherlock Holmes');
ReactDOM.render(h, document.getElementById('entry-point'));
</script>
</body>
</html>
Can anybody tell me what am I missing? It's showing "Uncaught ReferenceError: func is not defined" when I am clicking the button.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Admin</title>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
</head>
<body>
<div id="main">
<button onclick="func()">Click Me</button>
</div>
<script type="text/javascipt">
function func(){
alert("called func");
}
</script>
</body>
You mistyped javascript... see the type of the script
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Admin</title>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
</head>
<body>
<div id="main">
<button onclick="func()">Click Me</button>
</div>
<script type="text/javascript">
function func() {
alert("called func");
}
</script>
</body>
Typing Mistake . Replace "text/javascipt" to "text/javascript".
I need Eclipse(Kepler) to indent html tags within <head>...</head> when I hit Ctrl+Shift+F
Currently, this:
<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
function func() {
console.log("Hello world");
}
</script>
</head>
<body>
<p onclick="func()">Some text</p>
</body>
</html>
becomes this when I hit the key combination.
<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
function func() {
console.log("Hello world");
}
</script>
</head>
<body>
<p onclick="func()">Some text</p>
</body>
</html>
I need everything within <head>...</head> to be indented and also all the tags within <html>...</html>.
Ideally this way:
function func() {
console.log("Hello world");
}
<html>
<head>
<title>Insert title here</title>
<script type="text/javascript">
/* function */
</script>
</head>
<body>
<p onclick="func()">Some text</p>
</body>
</html>
You could try to go to:
Window > Preferences > Web > HTML Files > Editors.
Add/Remove what you want to indent from the inline field. From what I saw it doesn't include the head tag, so try adding in the list.
I'm getting an error that says "Tag start is not closed" in the following HTML code after the input tag. I can't seem to figure out why since I am using the Handlebars syntax properly. Can someone help me out please?:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="todo">
</div>
<script id="item-template" type="text/x-handlebars-template">
// Your code goes here
<div>
<input id="todo-complete" type="checkbox" {{#if completed}} "checked" {{/if}}>
<label>{{title}}</label>
</div>
</script>
<script src= "underscore.js"> </script>
<script src="handlebars-v1.3.0.js"> </script>
<script src="backbone.js"> </script>
<script src="jquery-1.11.1.js"> </script>
<script src="main.js"> </script>
</body>
You IDE doesn't understand Handlebars syntax, hence reporting a Error, which you should ignore.
this is sample code i tried n its working
<html>
<head>
<style>
<!--
.execute { background-color: red; height: 25px; }
-->
</style>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js">
</script>
<!-- Let's register a onClick handle for any .execute div. -->
</head>
<body>
<div class="execute">
<head>
<script>
dojo.ready(function() // Dojo will run this after being initialized
{
// Get A list of all tags with id execute and add a event onClick
dojo.query(".execute").connect("onclick", function(evt)
{
alert("Event triggered!");
// ...
});
});
</script>
</head>
<body>
Click me 1
</body>
</div>
<br /><br />
<div class="execute">Click me 2</div>
</body>
</html>
but if i merge it in another code it highlights and as invalid code. what does it means?
Ther are several code issues. double <head> tags, HTML elements after the <body> tag.
cleaned up code:
<html>
<head>
<style>
.execute { background-color: red; height: 25px; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js"></script>
<script>
dojo.ready(function() { // Dojo will run this after being initialized
// Get A list of all tags with id execute and add a event onClick
dojo.query(".execute").connect("onclick", function(evt) {
alert("Event triggered!");
// ...
});
});
</script>
</head>
<body>
<div class="execute">Click me 1</div>
<br><br>
<div class="execute">Click me 2</div>
</body>
</html>
<head> should only appear once, directly under the <html>, and not within <body>.
Exceptions to this are iframes embedded within existing pages, which have their own document structure.
Just remove the second <head>.
Why do you have two heads? <script>s don't have to be in <head>s.
You should only have a single <head> in your document.
The structure of an HTML page should be as follow:
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
Although they do not have to be, most people put script tags within the opening and closing header tags. For example:
<html>
<head>
<title></title>
<script>
<!--This is where all your functions should be.-->
</script>
</head>
<body>
</body>
</html>