Solved

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

Posted on 1998-09-14
2
316 Views
Last Modified: 2008-03-17
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?
0
Comment
Question by:bhelman
2 Comments
 
LVL 1

Accepted Solution

by:
cutetech earned 100 total points
ID: 1270843
You can try the following HTML out....

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

<SCRIPT LANGUAGE="JavaScript">
  function openGraphic(title,width,height,pic) {
    gWindow=window.open
        ("","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>")
  }
</SCRIPT>

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

</BODY>
</HTML>

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.

CuteTech
0
 

Author Comment

by:bhelman
ID: 1270844
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.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question