0

I want my iFrame window to show the URL I enter from the Form Text box, To that I want the iframe src="" to be changed to the form field input. How can I do that? Here is a sample code that I intent to use.

<html>
<head>
<title>Blah.</title>
<link href="style.css"rel="stylesheet" type="text/css" />
</head>
<body>
<form>
Enter URL: <input type="text" />
<input type="submit" value="GO" />
</form>
<iframe src="" frameborder="0" marginwidth="0" scrolling="yes"></iframe>
</body>
</html>

1 Answer 1

2

Try this.

<html>
<head>
    <title>Blah.</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function SetSrc()
        {
            document.getElementById("myIfreme").src = document.getElementById("txtSRC").value;
        }
    </script>
</head>
<body>
    <form>
    Enter URL:
    <input type="text" id="txtSRC" />
    <input type="button" value="GO" onclick="SetSrc()" />
    </form>
    <iframe id="myIfreme" src="" frameborder="0" marginwidth="0" scrolling="yes"></iframe>
</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.