PDA

View Full Version : iframe



otnj2ee
Sep 7th, 2007, 11:58 PM
First, create the iframe element

var newIframe = document.createElement('iframe');
newIframe['id'] = "testIFrame";
newIframe['src'] = '/blank.jsp';


Second, create a div element

var newDiv = document.createElement('div');
newDiv['id'] = "testDiv";


Third, append the elements:

var bodyRef = document.getElementsByTagName("body").item(0);

bodyRef.appendChild(newIframe);
bodyRef.appendChild(newDiv);


Fourth, load the data:
newDiv.innerHTML = "<div> This is a test </div>


And the text is loaded to the iframe and shown up.

Here, the blank.jsp is truely a blank jsp page containing nothing.


My question is, how could the content of the newDiv gets loaded to the iframe.


Thanks


Scott