473,797 Members | 3,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

new window with picture

Hello all!

I would like to open a new window with a picture after clicking on a
shrinked picture which is located on the main page. I want this new window
to be
exactly sized as original dimensions of this image.
Where is the error on the following code??? :

<SCRIPT LANGUAGE=JAVASC RIPT TYPE="TEXT/JAVASCRIPT">
function rozmiar(rysunec zek,id)
{
obrazek=new Image()
obrazek.scr=rys uneczek

if (id==1)
{
//rozmiar=obrazek .width
}
else
{
rozmiar=obrazek .height
}

}

function funkcja(rysunek )
{
oknoObrazka=win dow.open(rysune k,'oknoObr','to olbar=yes,locat ion=yes,scrollb a
rs=yes,width=' + rozmiar(rysunek ,1) + ',height=' + rozmiar(rysunek ,2))
oknoObrazka.foc us()
}

</SCRIPT>
......
<a href="javascrip t:funkcja('Wojt Stol_files/meble/100_0135.gif'); "><img
src="WojtStol_f iles/meble/100_0136.gif" width=150 height=100 border=1></a>
......

Thanks for help
Marcin from Poland
Jul 23 '05 #1
3 1451
Kamyk <ma************ **@poczta.onet. pl> wrote in message
news:d4******** **@news.onet.pl ...
Hello all!

I would like to open a new window with a picture after clicking on a
shrinked picture which is located on the main page. I want this new window
to be
exactly sized as original dimensions of this image.
Where is the error on the following code??? :

<SCRIPT LANGUAGE=JAVASC RIPT TYPE="TEXT/JAVASCRIPT">
function rozmiar(rysunec zek,id)
{
obrazek=new Image()
obrazek.scr=rys uneczek

if (id==1)
{
file://rozmiar=obrazek .width
}
else
{
rozmiar=obrazek .height
}

}

function funkcja(rysunek )
{
oknoObrazka=win dow.open(rysune k,'oknoObr','to olbar=yes,locat ion=yes,scrollb a rs=yes,width=' + rozmiar(rysunek ,1) + ',height=' + rozmiar(rysunek ,2))
oknoObrazka.foc us()
}

</SCRIPT>
.....
<a href="javascrip t:funkcja('Wojt Stol_files/meble/100_0135.gif'); "><img
src="WojtStol_f iles/meble/100_0136.gif" width=150 height=100 border=1></a>
obrazek.scr=rys uneczek Should be: obrazek.src=rys uneczek

Your function rozmiar() must be coded to return a value, or the statements:
width=' + rozmiar(rysunek ,1) and height=' + rozmiar(rysunek ,2) will evaluate
to undefined.

Having said that, if you want the dimensions to be calculated rather than
specified manually, it may be better to write the function so that it need
be called only once, by having it return a string of the form:
"width=w,height =h"
rozmiar=obraze k.height

This creates a global variable with the same name as the function, which has
the effect of destroying the function.

You still need further code to display the image in the new window.
--
Stephen Chalmers


Jul 23 '05 #2


--
--D. McKirahan
DM********@comc ast.net
"Kamyk" <ma************ **@poczta.onet. pl> wrote in message
news:d4******** **@news.onet.pl ...
Hello all!

I would like to open a new window with a picture after clicking on a
shrinked picture which is located on the main page. I want this new window
to be
exactly sized as original dimensions of this image.
Where is the error on the following code??? :

<SCRIPT LANGUAGE=JAVASC RIPT TYPE="TEXT/JAVASCRIPT">
function rozmiar(rysunec zek,id)
{
obrazek=new Image()
obrazek.scr=rys uneczek

if (id==1)
{
//rozmiar=obrazek .width
}
else
{
rozmiar=obrazek .height
}

}

function funkcja(rysunek )
{
oknoObrazka=win dow.open(rysune k,'oknoObr','to olbar=yes,locat ion=yes,scrollb a rs=yes,width=' + rozmiar(rysunek ,1) + ',height=' + rozmiar(rysunek ,2))
oknoObrazka.foc us()
}

</SCRIPT>
.....
<a href="javascrip t:funkcja('Wojt Stol_files/meble/100_0135.gif'); "><img
src="WojtStol_f iles/meble/100_0136.gif" width=150 height=100 border=1></a>
.....

Thanks for help
Marcin from Poland

One problem is that you misspelled ".src" as ".scr".

Try the following "as-is"; watch for word-wrap.

<html>
<head>
<title>Marcin.h tm</title>
<script type="text/javascript">
var x = 0;
var y = 0;
function rozmiar(rysunec zek) {
var obrazek = new Image();
obrazek.src = rysuneczek;
x = obrazek.width;
y = obrazek.height;
}
function funkcja(rysunek ) {
rozmiar(rysunek );
var z = "scrollbars=no, width=" + (x+20) + ",height=" + (y+20);
oknoObrazka=win dow.open(rysune k,'oknoObr',z);
}
</script>
</head>
<body>
<a href="javascrip t:funkcja('Wojt Stol_files/meble/100_0135.gif'); "<img src="WojtStol_f iles/meble/100_0136.gif" border="1" width="150" height="100"></a>
<hr>
<a
href="javascrip t:funkcja('http ://www.google.com/intl/en/images/logo.gif');"<img src="http://groups-beta.google.com/images/google_sm.gif"

border="1" width="143" height="59"></a>
</body>
</html>

The width and height are padded because of the default margins.

Why would you want "scrollbars=yes " if it's supposed to fit the new window?

Also, why include "toolbar=yes,lo cation=yes," as they clutter the new
window?
Jul 23 '05 #3
DU
McKirahan wrote:
--
--D. McKirahan
DM********@comc ast.net
"Kamyk" <ma************ **@poczta.onet. pl> wrote in message
news:d4******** **@news.onet.pl ...
Hello all!

I would like to open a new window with a picture after clicking on a
shrinked picture which is located on the main page. I want this new window
to be
exactly sized as original dimensions of this image.
Where is the error on the following code??? :

<SCRIPT LANGUAGE=JAVASC RIPT TYPE="TEXT/JAVASCRIPT">
function rozmiar(rysunec zek,id)
{
obrazek=new Image()
obrazek.scr=r ysuneczek

if (id==1)
{
//rozmiar=obrazek .width
}
else
{
rozmiar=obraz ek.height
}

}

function funkcja(rysunek )
{

oknoObrazka=win dow.open(rysune k,'oknoObr','to olbar=yes,locat ion=yes,scrollb a
rs=yes,width= ' + rozmiar(rysunek ,1) + ',height=' + rozmiar(rysunek ,2))
oknoObrazka.f ocus()
}

</SCRIPT>
.....
<a href="javascrip t:funkcja('Wojt Stol_files/meble/100_0135.gif'); "><img
src="WojtStol _files/meble/100_0136.gif" width=150 height=100 border=1></a>
.....

Thanks for help
Marcin from Poland

One problem is that you misspelled ".src" as ".scr".

Try the following "as-is"; watch for word-wrap.

<html>
<head>
<title>Marcin.h tm</title>
<script type="text/javascript">
var x = 0;
var y = 0;
function rozmiar(rysunec zek) {
var obrazek = new Image();
obrazek.src = rysuneczek;
x = obrazek.width;
y = obrazek.height;
}
function funkcja(rysunek ) {
rozmiar(rysunek );
var z = "scrollbars=no, width=" + (x+20) + ",height=" + (y+20);


The default margin on root element is 15 for top and bottom and 10 for
left and right in MSIE 6. So here, you have miscalculated the height
with +20. I noticed you removed scrollbars for no given reason when, if
your calculations are wrong or correct - whatever -, you should always
provide normal fallback mechanisms to take over. You removed implicitly
capability to resize the window for the user and you removed explicitly,
intentionally capability to scroll the window if needed, if content
overflows requested window dimensions.
oknoObrazka=win dow.open(rysune k,'oknoObr',z);
}
</script>
</head>
<body>
<a href="javascrip t:funkcja('Wojt Stol_files/meble/100_0135.gif'); "
<img src="WojtStol_f iles/meble/100_0136.gif" border="1" width="150"
height="100"></a>
<hr>
<a
href="javascrip t:funkcja('http ://www.google.com/intl/en/images/logo.gif');"
<img src="http://groups-beta.google.com/images/google_sm.gif"


border="1" width="143" height="59"></a>


If javascript support is disabled, then the user won't be able to view
the image at all. If the user uses Ctrl+click or middle-click on the
link, he won't be able to view the image at all.

Top Ten Web-Design Mistakes of 2002;
6. JavaScript in Links
http://www.useit.com/alertbox/20021223.html

comp.lang.javas cript FAQ:
"javascript :" links
http://jibbering.com/faq/#FAQ4_24
</body>
</html>

The width and height are padded because of the default margins.

Why would you want "scrollbars=yes " if it's supposed to fit the new window?
Just in case the designer miscalculated the margin on the root element.

Also, why include "toolbar=yes,lo cation=yes," as they clutter the new
window?


If the user wants to bookmark the page, removing toolbar and location
bar won't help. If the user wants to use the toolbar - whatever the
reason - say to print the image -, your code not only removes the
toolbar but also prevents the user from getting it back on.

DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Firefox 1.0.3 :)
Jul 23 '05 #4

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

Similar topics

2
3406
by: Dariusz | last post by:
I have a problem with a call a Javascript "window.open()" function which is executed as part of a PHP file when a user clicks on an thumbnail image. The PHP is executed which passes some variables to Javascript to execute the new window opening. But as it does this, the main window is loaded which is blank (the browser URL bar shows the URL of the URL passed to the PHP / Javascript script). I would like to keep the gallery page visible...
4
651
by: Phillip Parr | last post by:
Hello, I have a nice system where someone clicks on a picture to show the full version. This pops up in a window.open box. It works great, the only problem is that if the user clicks a second picture before closing the first then the new picture loads into the original popup box which is often a different size. How can i make them open in their own popup windows? Thanks
1
1483
by: Danny | last post by:
hi, lately i've been working on a website and i have used a bit of javascript although i'm not an expert in this mather. On the page there are 3 thumbnails and when you click on a thumbnail a window with a picture (and text) on it opens. Each thumbnail should open a window with a different picture. So this is where the problem comes in : no matter wich thumbnail I click on, it's always the same window with the same picture that opens......
7
4794
by: Merlin | last post by:
Hi there, I have a serious problem with opening a new window with the help of JavaScript. The problem only occures with Firefox. Once you click on the item which fires up the open function, the new window opens up, but in the background the original window loads the homepage. I cant find a way to fix this so the site remains in the old window. Please have a look, if you click on the picture with the car you will see the problem.
2
1418
by: MM | last post by:
I am using the following code to display an image in a seperate window. <form> <input type=button onClick='window.open("image1.jpg","","width=260,height=260,resizable=0,border=0")' value=Shhow Picture'> </form> I want the window to be the exact size of the image so I set the width
33
4081
by: randau | last post by:
Linking to a Targeted Browser Window I'd like to open reference links to other web sites in a separate browser window from the browser window hosting my own web site pages. The Link Target reserve word "_blank" opens a blank new browser window for every link, which can sometimes result in a lot of open browser windows. Is there no way to "reuse" a previously linked browser window and have it load the new web page in Foreground
0
1889
by: kloplop321 | last post by:
I found this code(vb only) and it does about the same thing(in vb, not vb .NET 2005) Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit 'Api Spy Example by PAT or JK 'Webpage: http://www.patorjk.com/
9
2602
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo" runat="server"/> <asp:Label ID="CompanyPicture" runat="server"/> I have 2 links that open the windows to preview these images. The previewed images are done on separate html pages that do nothing but display the
2
2060
by: jodleren | last post by:
Hi! I am making an option, which opens a small window with a picture in it and data about it. I just want a JS script, which will get the picture size, and then set the window accordingly? BR Sonnich
0
9685
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
9537
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
10246
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
10209
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7560
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
6803
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
5459
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
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

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.