Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open simple window without anything on it

Status
Not open for further replies.

ssphoenix

IS-IT--Management
Jan 22, 2001
306
US
Someone posted a while back the code to open a window without anything on it. What I want to do is create a procedure link which will point to a picture showing a detail shot. I want it to open in a small windows without nothing on it other then a close button.

Thanks in advance.
 
Here is an example to see how you can do that stuff:

<script>
<!--
function pop_win(){
var new_win=window.open(&quot;&quot;,&quot;New Window&quot;,&quot;width=400,height=200&quot;);
var innerHT=&quot;<html><body>&quot;;
innerHT+=&quot;<a href='javascript:self.close();'>Close Me!</a>&quot;;
innerHT+=&quot;<br>&quot;;
innerHT+=&quot;some text...&quot;;
innerHT+=&quot;an image:&quot;;
innerHT+=&quot;<img src='image.gif'>&quot;;
innerHT+=&quot;</body></html>&quot;;
new_win.innerHTML=innerHT;
}
//-->
</script>

<a href=&quot;javascript:pop_win();;&quot;>Click</a>

Rick
 
Rick,

Thanks for your post. However, I am unable to get this to work. I have a runtime error on line:
function pop_win(){

For some reason it does not like this function.

Help would be greatly appreciated.

Thanks
 
That is strange. I was sure it was right so I posted without testing, but on IE 6 I'm getting errors. Hmm. Anyway, this works fine now:

<script>
<!--
function pop_win(){
var new_win=window.open(&quot;&quot;,&quot;&quot;,&quot;width=400,height=200&quot;);
innerHT=&quot;<a href='javascript:self.close();'>Close Me!</a>&quot;;
innerHT+=&quot;<br>&quot;;
innerHT+=&quot;some text...&quot;;
innerHT+=&quot;an image:&quot;;
innerHT+=&quot;<img src='image.gif'>&quot;;
new_win.document.body.innerHTML=innerHT;
}
//-->
</script>

<a href=&quot;javascript:pop_win();&quot;>Click</a>

Rick
 
Rick,

Thanks again. The new code worked. However, I have another questions regarding your code. I need to put a picture in that new windows. When I do the picture is sqwed to the bottom left. Seems that there is a left and top margin that I cannot take out. Basically I want the picture to fill the new window completely.

Thanks again.
 
Change the image to this:

<img width=&quot;100%&quot; height=&quot;100%&quot;>

Rick
 
I used the same kind of idea in a tutorial I once made. I had thumbnails of what you should do in each step that you could click to enlarge. It took me a while to develop this script but you may want to try it out.

----------
Link Script
----------

function openimg1()
{

OpenWindow=window.open(&quot;images/toolbars.html&quot;,&quot;img1&quot;,&quot;width=305,height=288,scrollbars=0,status=0,resizable=0,fullscreen&quot;);

}

-----------
New Window File
-----------

<html><head><title>Will display in Non-JS Enabaled Browsers</title>

<script language=&quot;javascript&quot;>
<!--
if (document.all) {
window.resizeTo(350, 344);
window.moveTo(Math.floor((screen.width-297)/2), 5);
}
-->
</script>

</head>
<body onClick=&quot;window.close()&quot; marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 style=&quot;position:absolute; overflow-x:visible; overflow-y:visible>

<a href=&quot;#&quot;><img src=&quot;button-editor.bmp&quot; border=&quot;0&quot; alt=&quot;Click to Close&quot;></a>

</body>

-----------------

I took that directly from the file. What it does is resize the window to the specified size and it has no toolbars and stuff because the link that opened the window has them disabled.
 
All of the above posted examples are not comlpetely cross-browser.
I'd recommend using this:

function openImage(images, w, h) {

var windowprops = &quot;location=no,scrollbars=no,menubar=no,toolbar=no&quot; + &quot;,left=300,top=100&quot; + &quot;,width=&quot; + w + &quot;,height=&quot; + h + &quot;;&quot;

a = window.open(&quot;&quot;,&quot;popupimage&quot;,windowprops);
a.document.open();

a.document.write('<html><body topmargin=&quot;0&quot; leftmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot;>');

a.document.write(&quot;<a href='javascript:window.close()'><image src='&quot; + images + &quot;' width=&quot; + w + &quot; height=&quot; + h + &quot; border='0' alt=''></a>&quot;);

a.document.write('</body></html>');
a.document.close();
}

Call it like this:
<a ... onclick=&quot;openImage('big1.gif', 120, 90)&quot;><img scr=&quot;small1.gif&quot; ... alt=&quot;click to see enlarged&quot;></a>

This script works in all browsers (including old ones) and is more flexible: it opens popup window with the size equal to image size.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top