How to set input box value inside iframe using jQuery?

I have a form inside an iframe that needs to be manipulated from the main frame.

An IFrame is viewed when it pops up when a button is clicked in the main frame. It then contains a upload form with a hidden field called dir.

I want to set a hidden field before showing the form. I tried:

$('#upload_iframe').contents().find('#dir').val(dir);

... which is being executed. And the new value can be printed using alert () in the main frame. However, the iframe does not change its value. Can you help me understand why?

Thanks!

+3
source share
1 answer

I do not think this is possible on a single jQuery line. The solution I can think of is a bit confusing.

IFrame (, test.aspx, ). , URL- :

$("#upload_iframe").attr("src", "text.aspx?dir=YourDirTextHere");

.

+4

Source: https://habr.com/ru/post/1715687/


All Articles