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?
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?
- howtocreate.co.uk/tutorials/javascript/variables – My Head Hurts Commented Jul 17, 2012 at 19:20
- developer.mozilla/en/DOM/document.title – jbabey Commented Jul 17, 2012 at 19:21
- The title is incorrect as it implies a document can have variables. It's actually the script within a page that can have variables. – Lee Taylor Commented Jul 17, 2012 at 20:00
1 Answer
Reset to default 4<script>
var someVariable="someValue";
document.title = someVariable;
</script>