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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pop-up window issue 1

Status
Not open for further replies.

bubu

Programmer
Mar 3, 2002
463
0
0
RO
Hello guys!

I have a page with 20 small images (acting like buttons)...like a thumbnail gallery.

I made a JS function for opening a pop-up window when one of these small_images are pressed. The function looks like this:

function newWindow( url, title)
{
wnd = window.open(url, title, 'toolbar=no,location=no,status=1,scrollbars=no,resizable=no,width=490,height=380')
if(window.focus)
{
wnd.focus();
}
}


And on the small_images:

<a href="javascript: newWindow('large_image1.jpg', 'windowtitle');">small_image here</a>

So...as you can see from this code I am trying to open a pop-up window with a large_image ... a JPG file who's size is: W 490 and H 380px.

THE PROBLEM is that the pop-up window appears fine, the image is there but a white border (about 10px) appears in the left and top of the image...




Regards,
Dragos.


 
Change your function slightly:

Code:
function newWindow( url, title) {
    wnd = window.open('', title, 'status=1,width=490,height=380');
    wnd.document.writeln('<html><head><title>' + title);
    wnd.document.writeln('</title></head><body style="margin: 0;">');
    wnd.document.writeln('<img src="' + url + '" border="0">');
    wnd.document.writeln('</body></html>');
    if(window.focus) wnd.focus();
}

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Works like a charm!!!

Thanks you very much :)


Regards,
Dragos.


 
As far as you know...This is a crossbrowser accepted solution?

Star added!

Regards,
Dragos.


 
Correct.
The only thing I would add to be sure is this:

Code:
function newWindow( url, title) {
    wnd = window.open('', title, 'status=1,width=490,height=380');
    with (wnd.document) {
      open();
      writeln('<html><head><title>' + title);
      writeln('</title></head><body style="margin: 0;">');
      writeln('<img src="' + url + '" border="0">');
      writeln('</body></html>');
      close();
    }
    if(window.focus) wnd.focus();
}

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Thanks a lot!

Regards,
Dragos.


 
The only problem right now is that the title displaied in the pop-up window is not the title that i send as a variable from the link but the path to the file...

...with the first code everything works just fine.

Regards,
Dragos.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top