Solved

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

Posted on 1998-09-14
2
310 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now