Solved

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

Posted on 1998-09-14
2
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

729 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