1

I'm trying to replicate the script functionality of this site: http://responsinator.com/

The idea is to get the URL from the form and insert into a one or more iFrames.

Sorry I'm a bit of a noob. I thought this would be simple, but am stuck. This is where I'm at so far:

http://jsfiddle.net/xtpD5/

  function handleButtonEnterClick() {
    var textbox_value = document.getElementById("url_textbox").value;
    document.getElementById('myUrl').value = window.location;
    var form = document.getElementById('myForm');
    form.action = textbox_value;
    form.submit();
}

<div id="container">
<form action="" method="post" id="myForm">
    <p>Enter URL:</p>
    <input type="hidden" id="myUrl" name="url" />
    <input type="text" id="url_textbox" name="url_textbox" />
    <input type="button" id="button_enter" name="button_enter" 
           value="enter" onclick="handleButtonEnter" />
</form>
</div>

Thanks!

1
  • Where's this iframe you speak of? Commented Mar 15, 2013 at 13:39

1 Answer 1

1

Like this? http://jsfiddle.net/xtpD5/1/

You can just submit the form to the iframe via the target attribute. and it opens it in the iframe

function handleClick() {
    var url = document.getElementById('url_textbox').value;
    document.getElementById('myForm').action = url;
    return true;
}

<div id="container">
    <form action="" method="post" id="myForm" target='iframe'>
        <p>Enter URL:</p>
        <input type="hidden" id="myUrl" name="url" />
        <input type="text" id="url_textbox" name="url_textbox" />
        <input id="button_enter" name="button_enter" value="enter" type="submit" />
    </form>
</div>
<iframe name="iframe"></iframe>
Sign up to request clarification or add additional context in comments.

2 Comments

Amazing! This is going on a WordPress page. Next hurdle will be to get the script running on that. I think WP likes to load its jQuery first. Thanks for your help! I'll work on this today.
Oops, I would like this to loops n number of times. The script would need to insert the identical URL into several iFrames. Otherwise, tested and runs great on my WordPress test site.

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.