• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Dynamic writing graphic and text to javascript:window.open() browser

I have a need to open a secondary browser (window.open), open a JPeG image and a separate caption.  Can this be done in a dynamic fashion without having to create an HTML file for each JPG/Caption combination?
1 Solution
You can try the following HTML out....

<BODY BGCOLOR="#ffffff" TEXT="#000000">

  function openGraphic(title,width,height,pic) {
        ("","GraphicWindow","width=" + width + ",height=" + height +           ",titlebar=yes,toolbar=yes,scrollbars=yes,location=yes,status=yes,menubar=yes")
    gWindow.document.write("<HEAD><TITLE>" + title + "</TITLE></HEAD>")
    gWindow.document.write("<CENTER><IMG SRC=\"" + pic + "\"></CENTER>")

<A HREF="#" onclick="openGraphic('Testing',400,400,'example.jpg')">OPEN</A>


You only need to change the parameters of the openGraphic(). The 1st parameter is TITLE, the 2nd parameter is WIDTH, the 3rd is HEIGHT, and the 4th is FILENAME.

bhelmanAuthor Commented:
The problem was that I needed to include a caption under the graphic.  This solution goes 95% there.  In the second "gWindow.document.write" statement, I just needed to include a text statement at the end.

Works like a charm.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now