Jump to content


Photo

how to print the value of a variable in the inline frame


  • Please log in to reply
2 replies to this topic

#1 kharbat

kharbat
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 19 June 2006 - 12:39 PM

I have 2 pages

page1.htm

page2.htm

there is an inline frame in page one refers to page2...

the is a javascript in page2 such as

var inner_variable = "hello";

how can i print the value of this variable from the parent page "page1

Thanks

Ahmad

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 19 June 2006 - 04:46 PM

I am not really sure what do you mean by printing the value, but you can access the iframe document object using this code
<html>
<script>
var page2_doc = "";
function assign_page2(){
     page2_doc = document.getElementById('page2').contentWindow.document;
}
</head>
<body onload="assign_page2();">
<iframe id="page2" name="page2" src="page2.html"></iframe>
</body>
</html>

you can access any object in the page 2 using the page2_doc

P.S. Both pages must be in the same domain

NoGray.com


#3 kharbat

kharbat
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 19 June 2006 - 08:01 PM

thank you very much!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users