简体   繁体   English

提交页面时从iframe访问隐藏的元素

[英]accessing hidden element from iframe when page submited

I have a question like this. 我有这样的问题。 I have 2 pages in my web for example and page 1 when submited goes to page 2, and of course with it all its html form elements. 例如,我的网站中有2个页面,提交时的第1页转到第2页,当然还有其所有html表单元素。 My question here is i have an iframe in page1 so how to i send the hidden elements from the iframe to page 2 when( page1 is submited) 我的问题是我在page1中有一个iframe,所以当(提交page1时)如何将隐藏元素从iframe发送到页面2

try this script 试试这个脚本

<script language="JavaScript" type="text/javascript">

 function fun(iframeid,iframename){
  obj=document.getElementById(iframeid);
   if (obj.tagName=='IFRAME'){
   obj=window.frames[iframename].document.getElementId('myfield1ID').value;

  }
 }
 </script>

and then put the values in page1 hidden element and submit the page... 然后将值放在page1 hidden元素中并提交页面...

before the end of script 脚本结束之前

         document.getElementById('page1hiden').value=obj.value;

this script functiopn you must call it when presing the button to submit the page 1 to p2 此脚本功能您必须在按下按钮将页面1提交到p2时调用它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM