PDA

View Full Version : Placing img in DIV on another page



Fisher
05-04-2009, 03:59 PM
I am still pretty new at this so please bear with me and let me know if things are clear or not.

I am trying to get an image to open on a second page (targetpage.htm) within a specific div tag. I've been able to get the image to load into a div on the same page and the Target Page to open but have not been able to get the image to load on the Target Page in the new window. It almost seems that the browser window has forgotten the variable assigned when the new window is opened. I am guessing this is an easy thing to do, but I am not finding an answer anywhere. Please help! :)

Here is what I have so far.

Page One:

<script type="text/javascript">

var changeIt, img;
changeIt = function( imageName, objName )
{ img = '<img src="' + imageName + '">';
window.open( 'targetpage.html', target="_blank" );
document.getElementById( objName ).innerHTML = img;
};

</script>

</head>
<body>

<div id="content"></div>
<br>
<a href="javascript:void(changeIt('image1.jpg', 'content')());">Click Me!</a>

Target Page:

<script type="text/javascript">
document.getElementById('objName').src = 'img';
</script>

</head>

<body>

<div id="content"></div>
<br>
<img src="targetpageimage.gif" width="150" height="330" />

molendijk
05-05-2009, 01:56 PM
Script in page 1:


<script type="text/javascript">

var changeIt, img;
changeIt = function( imageName, objName )
{ img = '<img src="' + imageName + '">';
newwindow=window.open( 'targetpage.html', target="_blank" );
document.getElementById( objName ).innerHTML = img;

setTimeout('newwindow.document.getElementById("content").innerHTML=img',0)

};

</script>
===Arie Molendijk.