html - How do I create another window on top of a page using Javascript? -


i'm alittle confused how create page on top of page. want have page open with: hi ________.

then, when user types name in , presses enter, name saved page writes "hi [insert name here]!.

i'm not sure best course of action. should should use prompt, or input text box? how able save name provided? i'm not sure if there such effect?

i know how create text input box, , how make form press enter keyboard, don't know how put effect on top. how can make window on top of window?

so website prompts user

    <p>enter name</p>     <button onclick="myfunction()">try it</button>       <p id="demo"></p> 

after, page fills in name, name inserted script. page display name entered. example, "hi sam." in regular page. use version of this?

    <script>     function myfunction() {         var x = document.getelementbyid("mytext").value;         document.getelementbyid("demo").innerhtml = x;     }     </script> 

let me know if sounds confusing. can try elaborate further. i've tried looking similar question on stackoverflow before, , don't see 1 yet.

since have not mentioned framework angular or jquery in post guess new creating "dynamic" web pages javascript. can these things "pure javascript" in general need write more code. actual example, however, can made work relatively little changes , not effort, this:

function myfunction() {          var x = document.getelementbyid("mytext").value;          document.getelementbyid("demo").innerhtml = x;      }
<input type="text" id="mytext" placeholder="please enter name">  <button onclick="myfunction()">try it</button>  <div id="demo"></div>

in example no window applied. if want modal dialog use javascript window-method prompt()

var name = prompt("please enter name here", "suggested name"); 

instead of above input field:

function myfunction() {          var x = prompt("please enter name here", "suggested name");          document.getelementbyid("demo").innerhtml = x;      }
<button onclick="myfunction()">try it</button>  <div id="demo"></div>


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -