Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head><title>Blank page</title></head>
- <script>
- function setTitle(newTitle) {
- document.title = decodeURI(newTitle.replace(/_/g, " "));
- }
- function setTitleFromForm(e) {
- if (e.preventDefault) { e.preventDefault(); }
- var newTitleElem = document.getElementById("newTitle");
- var newTitle = newTitleElem.value;
- document.title = newTitle;
- var myURL = document.location + "";
- var newURL = myURL.replace(/[?#].*/, "") + "?" + newTitle;
- document.location = newURL;
- return false;
- }
- window.onload=function() {
- var form = document.getElementById("theForm");
- form.onsubmit = setTitleFromForm;
- var myURL = document.location + "";
- var currTitle = myURL.replace(/.*[?]/, "");
- setTitle(currTitle);
- var input = document.getElementById("newTitle");
- input.value = decodeURI(currTitle);
- input.focus();
- }
- </script>
- <style type="text/css">
- #notes, #newtitle { width: 400px; }
- #notes { height: 300px; }
- </style>
- <body>
- <form id="theForm" onSubmit="setTitleFromForm" method="get">
- <input type="text" id="newTitle" />
- <button type="submit">Set title</button>
- <br><br>
- <textarea id="notes">
- </textarea>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement