Results 1 to 2 of 2

Thread: Placing img in DIV on another page

  1. #1
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Placing img in DIV on another page

    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:
    Code:
    <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:
    Code:
    <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" />

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Script in page 1:
    Code:
    <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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •