Hello all!
Could you tell me where is the error on the below code, because the script
is sometimes
working correctly and sometimes is not working correctly. I want my new
window with picture
to be fitted/enlarged to original size. The page on the below address: http://www.kapy.bydg.pl/~marcinz/stolarnia/.
I have Windows XP and IE 6.0. and everything works correctly. If I run the
page on Win 2000, IE 5.0.
it is not good-working.
<SCRIPT LANGUAGE=JAVASC RIPT TYPE="TEXT/JAVASCRIPT">
function funkcja(rysunek )
{
obrazek=new Image()
obrazek.src=rys unek
zmienna_w=obraz ek.width+50
zmienna_h=obraz ek.height+50
zmienna='toolba r=yes,location= yes,scrollbars= yes,width=' + zmienna_w +
',height=' + zmienna_h
return window.open(rys unek,'oknoObr', zmienna)
}
</SCRIPT>
.....
<a href="#"
OnClick="funkcj a('WojtStol_fil es/drzwi/wewnetrzne/100_0114.gif'); "><img
src="WojtStol_f iles/drzwi/wewnetrzne/100_0114.gif" width=150 height=100
border=1></a>
...... 2 6701
Kamyk wrote: Could you tell me where is the error on the below code, because the script is sometimes working correctly and sometimes is not working correctly. [...] <SCRIPT LANGUAGE=JAVASC RIPT TYPE="TEXT/JAVASCRIPT">
Omit the deprecated `language' attribute. And although HTML is not
generally case-sensitive, you should use lowercase characters only
where possible.
function funkcja(rysunek ) {
obrazek=new Image()
^[1] [2]^^^^^ ^[3]
[1] Variables should always be declared, using the `var' keyword.
[2] Host objects like Image should be tested prior to usage:
<http://pointedears.de/scripts/test/whatami>, paragraph 2.
[3] Do not rely on automatic semicolon insertion but end all
statements with a semicolon.
obrazek.src=rys unek
zmienna_w=obraz ek.width+50 zmienna_h=obraz ek.height+50
Most certainly it does not work because image loading is done asynchronously
by the UA (while the script engine continues interpretation) and so the
`width' and `height' properties do not return proper values prior. You
should use the `onload' event which should fire once the image has been
loaded and so its dimensions can be obtained:
[...] <a href="#" OnClick="funkcj a('WojtStol_fil es/drzwi/wewnetrzne/100_0114.gif'); "><img src="WojtStol_f iles/drzwi/wewnetrzne/100_0114.gif" width=150 height=100 border=1></a>
The above will not work without script support. The below quick hack
should do:
var obrazek, intv, w;
function funkcja(rysunek )
{
if (typeof Image != "undefined" )
{
obrazek = new Image()
if (window.setInte rval)
{
intv = window.setInter val(
(function()
{
if (obrazek.loaded && w)
{
window.clearInt erval(intv);
if (w.innerWidth)
{
w.innerWidth = obrazek.width + 50;
}
else if (window.clientW idth)
{
w.clientWidth = obrazek.width + 50;
}
if (w.innerHeight)
{
w.innerHeight = obrazek.height + 50;
}
else if (w.clientHeight )
{
w.clientHeight = obrazek.height + 50;
}
if (w.focus) w.focus();
}
}).toString(),
100);
}
obrazek.onload = function()
{
this.loaded = true;
}
obrazek.src = rysunek;
return (w = window.open(
rysunek,
'oknoObr',
'toolbar=yes,lo cation=yes,scro llbars=yes'));
}
}
...
<a href="WojtStol_ files/drzwi/wewnetrzne/100_0114.png"
onclick="return !funkcja(this.h ref);"<img src="WojtStol_f iles/drzwi/wewnetrzne/100_0114_thumbn ail.png"
alt="Alternativ e text -- required!"
width="150" height="100" border="1"></a>
Another alternative which I consider more reliable than your (improved)
approach is generating an entire HTML document to contain the image in
the popup window and use the `onload' handler of either its `body'
element or the `img' element instead, as implemented in enlargeImg():
<http://pointedears.de/scripts/window.js>
PointedEars
Kamyk wrote: Could you tell me where is the error on the below code, because the script is sometimes working correctly and sometimes is not working correctly. [...] <SCRIPT LANGUAGE=JAVASC RIPT TYPE="TEXT/JAVASCRIPT">
Omit the deprecated `language' attribute. And although HTML is not
generally case-sensitive, you should use lowercase characters only
where possible.
function funkcja(rysunek ) {
obrazek=new Image()
^[1] [2]^^^^^ ^[3]
[1] Variables should always be declared, using the `var' keyword.
[2] Host objects like Image should be tested prior to usage:
<http://pointedears.de/scripts/test/whatami>, paragraph 2.
[3] Do not rely on automatic semicolon insertion but end all
statements with a semicolon.
obrazek.src=rys unek
zmienna_w=obraz ek.width+50 zmienna_h=obraz ek.height+50
Most certainly it does not work because image loading is done asynchronously
by the UA (while the script engine continues interpretation) and so the
`width' and `height' properties do not return proper values prior. You
should use the `onload' event which should fire once the image has been
loaded and so its dimensions can be obtained:
[...] <a href="#" OnClick="funkcj a('WojtStol_fil es/drzwi/wewnetrzne/100_0114.gif'); "><img src="WojtStol_f iles/drzwi/wewnetrzne/100_0114.gif" width=150 height=100 border=1></a>
The above will not work without script support. The below quick hack
should do:
var obrazek, intv, w;
function funkcja(rysunek )
{
if (typeof Image != "undefined" )
{
obrazek = new Image()
if (window.setInte rval)
{
intv = window.setInter val(
function()
{
if (obrazek.loaded && w)
{
window.clearInt erval(intv);
if (w.innerWidth)
{
w.innerWidth = obrazek.width + 50;
}
else if (window.clientW idth)
{
w.clientWidth = obrazek.width + 50;
}
if (w.innerHeight)
{
w.innerHeight = obrazek.height + 50;
}
else if (w.clientHeight )
{
w.clientHeight = obrazek.height + 50;
}
if (w.focus) w.focus();
}
},
100);
}
obrazek.onload = function()
{
this.loaded = true;
}
obrazek.src = rysunek;
return (w = window.open(
rysunek,
'oknoObr',
'toolbar=yes,lo cation=yes,scro llbars=yes'));
}
}
...
<a href="WojtStol_ files/drzwi/wewnetrzne/100_0114.png"
onclick="return !funkcja(this.h ref);"<img src="WojtStol_f iles/drzwi/wewnetrzne/100_0114_thumbn ail.png"
alt="Alternativ e text -- required!"
width="150" height="100" border="1"></a>
Another alternative which I consider more reliable than your (improved)
approach is generating an entire HTML document to contain the image in
the popup window and use the `onload' handler of either its `body'
element or the `img' element instead, as implemented in enlargeImg():
<http://pointedears.de/scripts/window.js>
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christian Kusenbach |
last post by:
Hello group!
I've a problem with JavaScript and IMG-Objects.
On my webpage I use a big image and several small images. If you click
on a small image, it executes a JavaScript to change the source of the
big image to the source of the small image.
It's working fine, but on some browsers (I use IE 6.0.2800.1106) the
image doesn't change properly.
I click on the image and the big image turns white. Now I have to
|
by: Derek |
last post by:
Hi,
I've built a rather large CGI that dumps a lot of data and a fairly
complex javascript app out to the client's browser. Granted this may
be poor style according to someone web design philosophy but that is
the way things need to work for now here. The problem I'm having is
that it appears that the browsers (IE, mozilla and netscape) are
sometimes getting confused about wether the javascript code is
running. By this I mean when I...
|
by: Tony G. |
last post by:
Hi there,
I have an APS 3 application, running on a Windows 2003 Web edition server -
it is a very busy website, and when users are click on certain links
(membership info), a new window i opened via javascript.
This new window is on the SAME website as where the user is located, but
just opened in HTTPS (secure) mode - the user can now examine memberhip terms
and continue to buy membership.
|
by: Andy |
last post by:
I'm not sure why my checkbox code is not working as per intended. It
always keeps saying "Please select the department" even though I check
the department... appreciate any help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Welcome to the Scripting Store</TITLE>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252">
<SCRIPT>
|
by: VK |
last post by:
A while ago I proposed to update info in the group FAQ section, but I
dropped the discussion using the approach "No matter what color the cat
is as long as it still hounts the mice". Over the last month I had
enough of extra proof that the cat doesn't hount mice anymore in more
and more situations. And the surrent sicretisme among array and hash is
the base for it.
I summarized all points in this article:...
| |
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: krishna |
last post by:
Below is the code.
language = asp.net/vb.net
private sub openW()
sResult = sResult & "<script language=javascript> mywindow = window.open('http://localhost/mohsaic/default.aspx?tc=Client/Manage'); "
sResult = sResult & "mywindow.parent.frames.location = 'http://localhost/treeview/treeview.aspx?m=c&pid=366826706'; "
|
by: Nathan Sokalski |
last post by:
I add several JavaScript events (onchange, onkeypress, etc.) to Controls
using the Add method of the Attributes collection. However, if the
JavaScript code contains certain characters, such as & or < or several
others, it converts them to html, such as & or < which can sometimes
cause my scripts not to work. How can I prevent ASP.NET from doing this?
Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
|
by: tshad |
last post by:
Using asp.net 2.0, I am finding that at times, the old javascript will still
be there.
I was working with it for a couple of hours and the changes seem to happen.
But at the end of the day, I found that my last changes weren't taking
affect.
I was trying to delete my "alerts" before doing a final build but even after
taking out all my alerts, when I built it and ran it - the alerts were still
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |