Skip to content

Instantly share code, notes, and snippets.

@balcsida
Last active February 26, 2023 20:39
Show Gist options
  • Save balcsida/91e528e55940f5a1055406112dd7b20c to your computer and use it in GitHub Desktop.
Save balcsida/91e528e55940f5a1055406112dd7b20c to your computer and use it in GitHub Desktop.
Iframe browser
<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. &quot;example.org&quot;)" 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