faqts : Computers : Programming : Languages : JavaScript : Language Core : Variables

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 5 people (20%) answered Yes
Recently 1 of 5 people (20%) answered Yes

Entry

How do you use a function variable from the parent page in the child page?

May 8th, 2002 06:43
Jean-Bernard Valentaten, Ted Ciotti, This is the code that I am using:


Ted wrote:
> ****************************************
> parent ~ index.html
>
> <script language="JavaScript">
> function PrintImage(Image2Print){
> window.open('print.html', 'print', 'width=500,height=500')
> }
> </script>
Well, if you modify this code, it will work:
<script language="JavaScript">
  var Image2Print = '';
  function PrintImage(myImg)
  {
    Image2Print = myImg
    window.open('print.html', 'print', 'width=500,height=500')
  }
</script>
That's it.
> <A href="JavaScript:PrintImage('01.jpg');"><img border="0" 
> src='01t.jpg' width="75" height="75"></a>
> ****************************************
> child ~ print.html
>
> <body onload="javascript:window.print();">
> <script language="JavaScript">
> document.write('<img border="0" src="'+parent.Image2Print+'">');
> </SCRIPT>
> 
> ****************************************
>
> 
> Thank you for your help!!
>
> Ted
Jean