user9296197
user9296197

Reputation: 11

Prepopulate form in an iFrame using string data

I have a scenario where one form leads to another and the second one is inside an iFrame. I wanted to figure out how to pass string data onto the form within the iFrame. I've tried a few JavaScript codes I found online but none are working

Upvotes: 1

Views: 249

Answers (2)

Ishey4
Ishey4

Reputation: 327

You cannot view/modify within an iframe. Even if you set CORS most browsers block a lot of functionality today. if you have control of both sites you can use post messages.

Upvotes: 1

Tom Lynch
Tom Lynch

Reputation: 66

if your iframe's id is 'if', this will give you the inner doc

var innerDoc = document.getElementById("if").contentDocument;

then you can find your element from there.

Upvotes: 0

Related Questions