Mike M
Mike M

Reputation: 35

Iframe’s document is undefined or null

My assignment is to create two iframes. In one have a catalog where you characteristics of shoes, socks and shirts. The data from the 1 iframe is not moving over to the second iframe.

It says document is undefined or null.

function doit() {
  window.frames[0].document.form1.txtprice.value = window.frames[1].document.form2.priceResult.value;
}

Upvotes: 1

Views: 292

Answers (1)

Barmar
Barmar

Reputation: 780663

To access the document in an iframe you use the contentDocument property.

  window.frames[0].contentDocument.form1.txtprice.value = window.frames[1].contentDocument.form2.priceResult.value;

Also, this will only work if both iframes are from the same domain as the original page.

Upvotes: 2

Related Questions