Hi,
i have a big problem...i'm using one jscript for resizing of all of my pics
in popUp...in main html i'm having many little pics and clicking on them
they open in popUp and resize to larger version of the same pic.
now, it works fine and sometimes when i click on little one it doesn't
resize well...
this is the code:
main.html
<a href="#" onclick="javasc ript:
window.open('/html/popUp.html','Ma lo','toolbar=0, location=0,dire ctories=0,st
atus=0,menubar= 0,scrollbars=0, resizable=0');r eturn false;">
<IMG src="/images/thumbs/Malo.jpg" border="0">
</a>
popUp.html
<script language="JavaS cript">
var pic = new Image();
var url='/images/pics/'+name+'.jpg'; // name='Malo' from main.html
pic.src = url;
function resizing(){
window.location =url;
var wid=pic.width+3 0; // sometimes pic.width=0 and wid=30 and
sometimes is OK
var hei=pic.height+ 50; // sometimes pic.height=0 and hei=50 and
sometimes is OK
alert("wid="+wi d+"\n"+"hei="+h ei);
window.resizeTo (wid, hei);
}
</script>
</head>
<body onload="javascr ipt: resizing();">
</body>
i don't know what hapens...maybe some pic doesn't have time to load so
pic.width and height is 0 but when i close popUp and open it again for the
same pic, it resizes well...i mean, the pic that resizes wrong second time
resizes well...
If someone know what i'm doing wrong help please!!!
Thank You very much! 10 2333
"riki" <ri******@hotma il.com> schrieb im Newsbeitrag
news:c1******** **@ls219.htnet. hr... Hi, i have a big problem...i'm using one jscript for resizing of all of my
pics in popUp...in main html i'm having many little pics and clicking on them they open in popUp and resize to larger version of the same pic. now, it works fine and sometimes when i click on little one it doesn't resize well... this is the code:
main.html
<a href="#" onclick="javasc ript:
window.open('/html/popUp.html','Ma lo','toolbar=0, location=0,dire ctories=0,st atus=0,menubar= 0,scrollbars=0, resizable=0');r eturn false;"> <IMG src="/images/thumbs/Malo.jpg" border="0"> </a>
popUp.html
<script language="JavaS cript"> var pic = new Image(); var url='/images/pics/'+name+'.jpg'; // name='Malo' from main.html pic.src = url; function resizing(){ window.location =url; var wid=pic.width+3 0; // sometimes pic.width=0 and wid=30 and sometimes is OK var hei=pic.height+ 50; // sometimes pic.height=0 and hei=50 and sometimes is OK alert("wid="+wi d+"\n"+"hei="+h ei); window.resizeTo (wid, hei); } </script>
</head>
<body onload="javascr ipt: resizing();">
</body>
i don't know what hapens...maybe some pic doesn't have time to load so pic.width and height is 0 but when i close popUp and open it again for the same pic, it resizes well...i mean, the pic that resizes wrong second time resizes well... If someone know what i'm doing wrong help please!!! Thank You very much!
Sorry I don't comment your script - the idea of resizing images with
Javascript just seems very strange to me. You should make two different
image files, one for the thumbnail and one for the big view. Resized
pictures always look bad on screen, as pixels are interpolated or even
extrapolated.
And: If you increase the size you don't have enough data, and if you make it
smaller you transfer too much data.
--
Markus
yes i have two different image files of the same pic...little ones in the
/images/thumbs/ folder and big ones in the /images/pics/ folder...
acctually i'm trying to resize html popUp window to the widht and height of
the pics dimension that opens in it...
i'm not trying to resize the acctuall pic itself
"riki" <ri******@hotma il.com> schrieb im Newsbeitrag
news:c1******** **@ls219.htnet. hr... acctually i'm trying to resize html popUp window to the widht and height
of the pics dimension that opens in it... i'm not trying to resize the acctuall pic itself
I see... so I had a look at your code. At first sight it is actually strange
that it sometimes works. The url and pic variables are declared as local
(with "var") so they should not be valid inside the function. You can try
the following:
- either remove all appearances of "var"
- or remove the function. Just delete the "function resizing(){" and "}"
lines in the script section and the onLoad handler in the body tag. If the
code is not embedded in the function it will be executed on load
automatically, and all variables will be recognised.
HTH
Markus
thank you very much Markus...I'll try that later when i'll come home.
tell you results tomorow
Markus Ernst wrote:
<snip> I see... so I had a look at your code. At first sight it is actually strange that it sometimes works.
It is not that strange. Sometimes working is the best that can be hoped
for from this script but even in a supporting environment the
asynchronous loading of the image file that may result for assigning a
value to the - src - popery of an Image object, combined with the
asynchronous replacement of the current execution context invoked by
assigning a value to the - window.location - object, will mean that the
viability of reading width and height values from the Image object will
depend on many local and network performance and caching variables. If
the image file has not been loaded/processed to the point of making its
dimensions available (assuming the implementation does that anyway, not
all do) or the - pic - global variable is destroyed by the instruction
to replace the current page, then there is little chance of being able
to read the width and height of the image.
The url and pic variables are declared as local (with "var") so they should not be valid inside the function.
<snip>
Those variables are declared in the global context so they will be
global variables and should be available from within the function
(subject to there possibly being freed as a consequence of the
assignment to window.location ).
Richard.
riki wrote: thank you very much Markus...I'll try that later when i'll come home. tell you results tomorow
Here's one way to detect the image dimensions, it requires that images
be preloaded so it won't be useful for sites where preloading would take
too much time: http://www.fontstuff.com/mailbag/qfrontpage01.htm
From the web page...
"In my tutorial Making a Browser Window Fit an Image I showed how you
can use JavaScript to open an image in its own window, exactly sized to
fit the image. The code uses a hyperlink that calls a JavaScript
function, and provides it with the URL of the image to be displayed, as
well as its height and width in pixels. But can the same thing be
achieved without knowing the size of the image?
The answer is yes - providing the images are preloaded by the browser.
Here's an example:"
<script language="javas cript" type="text/javascript">
// preload image files
image_1 = new Image()
image_1.src = "../images/qfrontpage01a.j pg"
image_2 = new Image()
image_2.src = "../images/qfrontpage01b.j pg"
image_3 = new Image()
image_3.src = "../images/qfrontpage01c.j pg"
// DetectImageSize function
function DetectImageSize (picName,picTit le){
picURL=picName. src
newWindow=windo w.open(picURL,' newWin','toolba r=no,
width='+picName .width+',height ='+picName.heig ht)
newWindow.docum ent.write('<htm l><head><title> '+picTitle+'
<\/title><\/head><body background="'+p icURL+'"><\/body><\/html>')
newWindow.resiz eBy(picName.wid th-newWindow.docum ent.body.client Width,
picName.height-newWindow.docum ent.body.client Height)
newWindow.focus ()
}
//-->
</script>
riki wrote: thank you very much Markus...I'll try that later when i'll come home. tell you results tomorow
Here's a different way to do it, there is a delay while the image is
loaded before it can be displayed, if you use this I'd let the user know
something is happening while they wait (on slower connections). http://www.webxpertz.net/faqs/jsfaq/popup.php#popupimg
How can I open a window the size of an image?
You can load the image, find out dynamically what size it is, and then
open a window the size you need.
<html>
<head>
<title> Popup Images </title>
<script type="text/javascript">
function popup(url,windo wname,width,hei ght) {
width=(width)?w idth:screen.wid th/3;
height=(height) ?height:screen. height/3;
var screenX = (screen.width/2 - width/2);
var screenY = (screen.height/2 - height/2);
var features= "width=" + width + ",height=" + height;
features += ",screenX=" + screenX + ",left=" + screenX;
features += ",screenY=" + screenY +",top=" + screenY;
var mywin=window.op en(url, windowname, features);
if (mywin)
mywin.focus();
return mywin;
}
var myimage = new Image();
var popupwin=null;
myimage.onload= function(){
popupwin=popup( this.src,"pic", this.width+20,t his.height+20)
}
function foo(what){
if (popupwin && !popupwin.close d)popupwin.clos e();
myimage.src=wha t;
}
</script>
</head>
<body>
<a href="IMG_0143. jpg" onclick="foo(th is.href);return false;">Her
Indoors</a>
<a href="IMG_0156. jpg" onclick="foo(th is.href);return false;">One Little
Angel</a>
</body>
</html>
thank you all very much for your answers...
i'll have to think what's the easiest way to solve this...
i'm having about 20 thumbs per page and each big pic that opens in popUp is
7 or 8 kb in size.
if i'm using preloading like this:
//preload image files
image_1 = new Image()
image_1.src = "../images/pics/bigpicname1.jpg "
image_2 = new Image()
image_2.src = "../images/pics/bigpicname2.jpg "
image_3 = new Image()
image_3.src = "../images/pics/bigpicname3.jpg "
etc. etc...
can i call later this pic "bigpicname1.jp g" (by it's name) or just "image_1"
(preloaded img)???
if i must call every pic like "image_#" what hapens if i call "image_20" and
only the first 10 has preloaded??? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alex Hopson |
last post by:
I'm using the code below to loop through some images and resize each image
twice, once to create a thumbnail and once to create a small image.
The page stops loading around the 38th image out of 40+. Not always the same
place but it's either 38th or 39th image, which I find strange as it's not
consistent.
At first I thought it was a timeout problem so I added - set_time_limit(0);
and ignore_user_abort (true); to prevent it timing out,...
|
by: Søren Reinke |
last post by:
Hi there
I have a little problem.
How do i make sure that a graph is not redrawn while the form with the graph
is being resized ?
I have tried to add a mouse up/down event handler on the form1, but it
dosn't get called when resizing :(
I would like to be able to resize my form, but also make sure the graph is
|
by: bruno |
last post by:
I have a .aspx with a TreeView in the left hand and a GridView or a FormView
in the right hand. I would like to resize the two sides like in
http://msdn.microsoft.com/library/default.asp, but I didn't find the solution.
Can I get any help? Just a sample or a link to where I can learn about.
Thank you very much.
--
bruno
|
by: tomasio |
last post by:
Dear NG,
years have passed and I am still more designer than programmer. I
build a new version of my website which has a few nasty bugs,
especially on my startpage: Resizing text brakes the dotted lines
which I use as visual border on the left and right edge of the page
layout and thus produces an unwanted white gap above the enlarged
text. Viewing the page with IE shows this behaviour even without
changing the font size.
|
by: Nick ! |
last post by:
Chris Share <usenet at caesium.me.ukwrote:
http://web.cs.mun.ca/~rod/ncurses/ncurses.html#xterm says "The ncurses
library does not catch signal, because it
cannot in general know how you want the screen re-painted". First, is
this really true? When I make my xterms smaller they clip what is
displayed--is that a function of curses or the xterm?
Second, if true, it explains /what/ is going on--stdscr, only--, but
isn't really...
| |
by: JDeats |
last post by:
I have a WinForms based application written for the .NET Framework 2.0
and in this application I need to be able to be able to take some
action in code when the user finishes resizing the form.
I can easily create an event handler for the SizeChanged form level
event, the problem is if the user is using a mouse drag to resize the
form this event is firing every few milliseconds or what have you
until the user stops the drag process.
...
|
by: dli07 |
last post by:
Hello,
I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's based on a post from http://blogs.crankygoblin.com/blogs/geoff.appleby/pages/50712.aspx. I've also read the post on this topic by bggraphics, but he doesn't arrive at a final result. The main problem I am having is that the layerX and layerY event properties don't work. They're supposed to return the...
|
by: Steve |
last post by:
Hi All
I have written some code to rescale my windows forms application forms
depending on the users screen resolution
The application is designed for 1024 x 768 but some customers have 19"
screens and want to use 1280 x 1024 etc
I am using vb.net 2005
Code sample..............................................................
|
by: mishrarajesh44 |
last post by:
hii all,
I am facing a problem currently..
i have a script for image uploading and resizing..
the image uploading takes place properly for every size images..
but, the resizing works for only small sized iamages..
for eg. resizing takes place for 70 kb sized images but fails for 600kb or more..
my code is below..
|
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...
|
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: 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,...
|
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: 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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |