473,769 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need help opening a window

MM
I am using the following code to display an image in a seperate
window.

<form>
<input type=button
onClick='window .open("image1.j pg","","width=2 60,height=260,r esizable=0,bord er=0")'
value=Shhow Picture'>
</form>

I want the window to be the exact size of the image so I set the width
and height of the window the same as the width & height of the image.

The code works, however there is a white border on the top and left
side of the image. If I add 20 to the width and height of the window
then there is a white border around the whole image.

Is there anyway to have the window the exact size of the image,
without this white border? I know there is probably a simple solution,
but I'm a beginner at JavaScript.

Any help is much appreciated.
Jul 23 '05 #1
2 1416

"MM" <ca***********@ yahoo.ca> wrote in message
news:jv******** *************** *********@4ax.c om...
I am using the following code to display an image in a seperate
window.


do you really need a new window? I think "thumbnail> big image in new
window" is a pita. also, pop up blockers will block you.

sorry to not answer your ?.
Jul 23 '05 #2
MM wrote:
I am using the following code to display an image in a seperate
window.

<form>
<input type=button
onClick='window .open("image1.j pg","","width=2 60,height=260,r esizable=0,bord er=0")'
value=Shhow Picture'>
</form>

I want the window to be the exact size of the image so I set the width
and height of the window the same as the width & height of the image.


You can't reliably do this for all browsers. Some automatically put a
margin of 20px or so on all <body> tags by default. Some also add it
when showing just an image, but others not. Safari adds it when
showing a page, but not when showing an image.

Even if you manage to set the margin to 0, some browsers will leave a
border on the other side of the image (IE on Mac). So the simplest
solution is to put all your images into HTML documents and load those
(setting margin to 0).

Another solution is to leave a good margin of say 50px around the
image and set your background to some compatible colour (black seems to
be the most common choice). For an image of width 300 and height 200,
create a window of an extra 100px and add 50px padding to the image:

<script type="text/javascript">
function showPic(t,u,w,h ) {
w -= -100;
h -= -100
newWin = window.open('', '','height=' + h + ',width=' + w);

var sHTML = [
'<html><head><t itle>' + t + '</title></head><body',
' style=\'margin: 0; background-color: black;',
' color: black;\'><img src=\'' + u + '\'',
' alt=\'\' border=\'0\' style=\'padding : 50 0 0 50\'>',
'</body></html>'
];

newWin.document .write(sHTML.jo in(''));
newWin.document .close();
}
</script>

</head><body>

<form action="">
<input type="button" value="Show Picture" onClick="
showPic('A Picture','image 1.jpg','300','2 00');
">
</form>

Incidentally, pop-up blockers will normally allow pop-ups in response
to user actions, but some allow even those to be blocked. Some also
allow exceptions for certain sites.

But in general, pop-ups are bad.

--
Rob
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4231
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link, which when you click it bookmarks the site (much easier). The favicon is never saved if the site is bookmarked this way. Does anyone have any ideas how to fix this?? This is the code: <script language="JavaScript">
3
5197
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same image. What I would like to create is a link that can be clicked on to close the window that contains the larger image. This would make it easier for the users to close the window. I have posted the script that I use. Any help would be much...
2
7042
by: Dena Leiter | last post by:
I want to send people to a new page using a redirect but I want a new window to open. Is this possible? I've tried this: <meta http-equiv="refresh" content="0;url=http://search.epnet.com/direct.asp?jn=HBR&db=bch target=_blank"> but it doesn't open a new browser window. Is there a way to do this?
2
2319
by: tmb | last post by:
- Want to open a 2nd browser window when someone clinks a link with the link content inside it. - Want to control window size - Want all tool bars so only blue bar at top shows - Can I put my content in the blue bar? - Only options are Minimize, Maximize or Close (top right of blue bar) 1 - What is the difference in 'OpenWindow' and 'Spawn' ?? 2 - Can anyone point me to a simple script I can use... or just post one...
1
1530
by: Jarrod Hyder | last post by:
Ok, I wrote my own weblog and I'm working on the web interface for adding/editing my posts. I decided to add a little preview button...when the button is clicked it is suppose to open a pop-up window. I wrote the whole preview function in javascript so that I don't have to reload the page to see a preview. Here is the code I wrote that doesn't work at all: Code:
14
11095
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin = window.open('images/KJV-THANKS.gif', 'Thanks', 'width=243,height=420,'); cwin.focus();
2
1791
by: Keshav Gadia | last post by:
Hi, I am an ASP.net newbie. I am writing a user control that is made up of datagrid with one of the columns opening a new window to display some details on click of the set image. I have basically used ImageButton server control. The problem is because I have used a server control with runat="server",the parent page is posted back and even though the window opens up,the focus gets set to the parent window. What I want is,the new window...
5
2164
by: Roger Withnell | last post by:
This is a framed webpage with the navigation bar in "NavBar" and the main window in "Main". When opening a new page in "Main" from "NavBar" with: function OpenFrameWindow(src) { var NewWindow = window.open(src, "Main"); NewWindow.focus(); }
7
2536
by: fox | last post by:
Hi, Lacking javascript knowledge, I just realized why my project has a bug. I am using ASP to loop through a set of records while it creates URLs with a querystring that has a single value pair. This URL needs to open in a floating window if clicked. (this is for an administrator and so opening a small floater gives them more efficient access to the data that will be displayed). I now understand that because the ASP executes first, that...
1
11077
by: sandy21380 | last post by:
Hello, Is there a way of opening an Access form without opening the Access window? Right now when I open the form, the Access window is a lot bigger than the form so I have to resize the Access window so it doesn't take up my whole screen (the form is about 2" x 3"). If there is no way to open only the form without the Access window opening, is there a way to automatically set the size of the Access window and close the menu bar?\ Thanks!
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.