SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot matches's Avatar
    Join Date
    Aug 2006
    0 Post(s)
    0 Thread(s)

    form within an iframe

    Hello, I have a form within an iframe. I would like the returned results to display outside of the iframe and inside the containing the page. I have done this with the links inside the iframe by including <base target="_" />. That has made all my links result outside of the iframe.

    Does anyone know how to accomplish this? Below is the form and the function that it calls

    HTML Code:
    <form name="kwsearchbar" action="javascript:validateAndForward(document.kwsearchbar);" onsubmit="javascript:validateAndForward(document.kwsearchbar);" >
    function validateAndForward(aForm) {
        var textStr = aForm.qt.value;
        if (!isValidString(textStr)) {
            alert("You must enter a search term.");
        } else {
            var keyword = encodeKeywordSearch(textStr, "urlenc");
            window.location = "/" + aForm.nodeid.value + "/" + keyword + ".html";

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Ventura, CA
    0 Post(s)
    0 Thread(s)
    If you want to reference elements inside an iframe, you need to grab the iFrame's document reference. I put a function in another thread to do this:

    Code JavaScript:
    function getIframeDocument(element)
        var doc = element.contentDocument;
            if (doc == undefined || doc == null)
             doc = element.contentWindow.document;
        return doc;

    where element is a reference to the iframe node (usually retrieved through document.getElementById('iframe_id')). Once you have this you can use the returned value to do things like getElementById and getElementsByTagName to retrieve iFrame node values.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts