The js declared traversal does not get the value of the variable

dzqfengxiang 注册会员
2023-02-27 19:16

When you write an event to the input the iframe is not loaded yet so you can't get the value you should change it to something like this so that when you click on it it's loaded

<iframe src="2.html" id="i">iframe>
<input type="button" onclick="get()" value="输出iframe中变量" />
        function get(){

dls081x 注册会员
2023-02-27 19:16

let declared variable will not be attached to the window variable, if not, var will be attached to the window variable.

asdw7540522 注册会员
2023-02-27 19:16

i do not define
directly output role, do not write i.ctentWindow. role
i is the id of iframe, It's not the name of the variable
or you can use find to get an instance of the control.

About the Author

Question Info

Publish Time
2023-02-27 19:16
Update Time
2023-02-27 19:16