0

In my web page, users can click on inputs which are check boxes. Later in their browsing, the options they chose cause other html documents to be displayed in the page they are in. At least that's the idea.

So, User A clicks check boxes for "Doc1" and "Doc4". An ajax call goes out to a web service and pulls these documents back. They are html. The callback method should take this html and insert it into the page.

I tried using an iframe, however that seems to require the src attribute to be specified. The html that comes back is a full page including . This would be on an HTML5 compatible browser only.

Is this possible, or should I be looking at something other than iframe?

9
  • 1
    If you would like to simply inject HTML code on an existing page on-the-fly, that is definetly doable (and done pretty commonly). You shouldn't need to use an iframe for that (if I understand correctly). If you can show us some code, it will be a lot easier to help. Commented Nov 15, 2012 at 20:15
  • why do you have to send an ajax call? can't you create an iframe on the fly and set its src to the same url you currently send the ajax call to? Commented Nov 15, 2012 at 20:16
  • FYI: IE6 will generate an error if no SRC is specified. Commented Nov 15, 2012 at 20:19
  • You can have an iFrame without src, at least on modern browsers. Commented Nov 15, 2012 at 20:19
  • @aamr1 - I am using iframe because I am not simply making and inserting a div. I am inserting an entire page complete with <head> and styles. Commented Nov 15, 2012 at 20:57

1 Answer 1

1

I solved this as follows:

  • User checks a couple check boxes and clicks 'next'.
  • AJAX call goes out to retrieve those documents associated with the checkboxes.
  • The page displaying retrieves this data, and creates iframes as needed.
  • SRC cannot be specified because there is NO url!
  • IE doesn't support ...'> because 2083 chars is the limit for IE.
  • Final solution is to write manually to the iframe:
var target = document.getElementById(someIframe).contentDocument;
target.open();
target.write(documentReceivedFromAJAXCall);
target.close();
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.