Last active
February 26, 2023 20:39
-
-
Save balcsida/91e528e55940f5a1055406112dd7b20c to your computer and use it in GitHub Desktop.
Iframe browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function(d){ | |
var init = function(){ | |
var form = d.getElementById("my_form"), input = d.getElementById("url"), iframe = d.getElementById("browser"); | |
form.addEventListener("submit", function(e){ | |
var val = input.value; | |
if(val) { | |
iframe.src = "//" + val; | |
console.log(val); | |
} | |
e.preventDefault(); | |
}, false); | |
}; | |
d.addEventListener("DOMContentLoaded", init, false); | |
})(document); | |
</script> | |
<form method="post" target="browser" id="my_form"> | |
<input style="width:120%;" placeholder="Put the website here (eg. "example.org")" name="url" id="url" type="text" /> | |
<input style="width:8%;" name="submit" type="button" value="Go" /> | |
<iframe name="browser" frameBorder="0" id="browser" src="" style="height:100%; width:100%"></iframe> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment