Nizar Barkallah
Nizar Barkallah

Reputation: 109

Declare variable in the beginning of a html document

In PHP we can declare variables in the beginning of the document this way:

<?php
$title="Title of the webpage";
?>

In the html code this title will replace the echo $title in the html code of the webpage. Is it possible to do it using html and Javascript, I mean without using PHP?

Upvotes: 2

Views: 10399

Answers (1)

Lance
Lance

Reputation: 1897

<script>
var someVariable="someValue";
document.title = someVariable;
</script>

Upvotes: 4

Related Questions