/    Sign up×
Community /Pin to ProfileBookmark

JavaScript page is blank (empty white). What should I do?

I am new at JavaScript.

I tried different web browsers (Chrome and IE). I tried different JavaScript code (e.g., to check the version of JQuery or to print “Hello World” in an alert box) that I got off the Internet. Nothing works. I use tags like this:

<html>
<body>
<script>

I use closing tags like these:

</script>
</body>
</html>

I tried .js extensions of different files of JavaScript code with the tags above. But these didn’t work. The .jsp extensions render completely white pages with no content. How do I get the content of JavaScript to render and display properly?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJun 08.2016 — I am new at JavaScript.

I tried different web browsers (Chrome and IE). I tried different JavaScript code (e.g., to check the version of JQuery or to print "Hello World" in an alert box) that I got off the Internet. Nothing works. I use tags like this:

<html>
<body>
<script>


I use closing tags like these:

</script>
</body>
</html>


I tried .js extensions of different files of JavaScript code with the tags above. But these didn't work. The .jsp extensions render completely white pages with no content. How do I get the content of JavaScript to render and display properly?[/QUOTE]


What does the rest of your code look like?

What you have posted will only display a blank page (as expected).
Copy linkTweet thisAlerts:
@ZorgJun 08.2016 — FYI:

[B]JavaScript[/B] is commonly used as a client side programming language with a file extension of [B].js[/B] (this code runs on the browser) and [B].jsp[/B] is a server side programming language for [B]JavaServer Pages[/B] (this runs on the server). The names are similar but these are not the same programming language.

If your trying to run the code above with the [I]<html>your code</html>[/I] tags then the file must have an extension of .html, not .js - HTML files commonly contain JavaScript and CSS.

[B]Example:[/B]

Copy this and name your file index.html - open it in the browser.
[code=html]
<!DOCTYPE html>
<html>

<!-- anything in this head tag runs first -->
<head>
<title>JavaScript Use</title>
<!-- put javascipt with in the head element -->
<script>
alert('Hello World'); // this will create a popup alert that says Hello World before the page loads completely
</script>
</head>

<!-- anything in this body tag runs next -->
<body>

<h1>JavaScript Use</h1>
<p>The button below also uses JavaScript when you click on it.</p>

<button type="button"
onclick="document.getElementById('hello').innerHTML = 'Hello Again!'">
Click me for a nice greeting.</button>

<p id="hello">This text will disappear...</p>

<!-- if you put javascipt before the closing body tag, it will run after everything above loads-->
<script>
document.getElementById('hello').innerHTML = 'TADAAAAH!'; // This text will be in the <p id="hello"></p> after the page loads.
</script>

</body>
</html>
[/code]
×

Success!

Help @Jitendra11 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...