0

I was wondering if anyone could help me with making a program in HTML that looks like this:

<html> <body> <script> var iframesite = prompt ('Enter in a site'); </script> <iframe src="?"></iframe> </body> </html> 

So what would I put in the place of the "?" ? I want it to be javascript inside of the src attribute so that I can put 'https:// ' + iframesite for a src.

Thanks

2

2 Answers 2

1

If you want to use plain javascript you can achieve this with something like this:

var iframesite = prompt ('Enter in a site'); document.getElementsByTagName("iframe")[0].setAttribute("src", "https://" + iframesite ); 

Otherwise I would suggest you to have a look at jquery

Sign up to request clarification or add additional context in comments.

Comments

0

I think adding a Iframe would work. Here is some example code:

var iframesite = prompt ('Enter in a site'); var iframe = document.createElement('iframe'); iframe.src = iframesite; document.body.appendChild(iframe); 

1 Comment

@PinkTurtle You can get never enough help ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.