-2

fellow programmers!!! I know this sounds really dumb, but I'm currently trying to embed an iframe in a website. I want the website to ask the user for a website... then when that happens it activates the iframe code. here is my idea for code to give you a better idea...

<iframe src = "http://" + input></iframe>

obviously this doesn't work, even I know that... but what would make this work? or if it doesn't work, is there any way to unblock a website from a school chromebook, or could I write a program that could do that. :) This probably won't get answered because it's extremely stupid, but I'd love any help I can get.

Joshua Reid
  • 61
  • 1
  • 9

2 Answers2

0

Try this

<HTML>
<iframe id="urlframe" src=""></iframe>
<script>
function askforsite() {
var url = prompt("Enter site URL: ");
document.getElementById("urlframe").setAttribute("arc", "http://"+url);
}
</script>
<body onLoad="askforsite();"></body></HTML>
Qwerty
  • 1,252
  • 1
  • 11
  • 23
0

Very similar, but with a form so you can reuse it:

<input type="text" id="url">
<button onclick="showURL()">Show Website</button>
<iframe id="newPage" src = ""></iframe>
<script>
  function showURL() {
    var url = document.getElementById("url").value;
    document.getElementById('newPage').src = url;
  }
</script>

You may have some issues with "Refused to display in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'" from some sites though.

Community
  • 1
  • 1
KAS
  • 53
  • 1
  • 5
  • Okay. Yea. I'm pretty new to html, I know a lot, but I didn't know script was a thing. Actually me and a buddy of mine were trying something to create a program to grab the most popular projects from a site, and we failed terribly. But, it was fun because he didn't know hardly any java, and I knew what it all meant, I'd just never seen it before. – Joshua Reid Jan 09 '17 at 02:38
  • I'll see if this works and tell you if it works. I think it will though. – Joshua Reid Jan 09 '17 at 02:39
  • OMG It works. Thanks :D Check it out - http://wchsunblocked.weebly.com/unblocked-pages.html. – Joshua Reid Jan 09 '17 at 13:08