473,654 Members | 3,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with image display please...

DDL
I am trying to create a simple web gallery to swap my images at
http://dev.lenosphotography.com

Go to the family section (should open a image bar at bottom - you may have
to scroll down - I have not finalized placement) - when you click on the
image thumbnail it calls a page (passing the reference to the "image name"
with this code. The swapfade code basicall swaps via fading one image for
another.. so I load the blank jpg with the size set to the real images W/H -
then call the swapfade function...

<script language="javas cript1.2" type="text/javascript">

var iWidth = 0;
var iHeight = 0;

img1 = new Image();
img1.src = '<%=Request.Que ryString( "photo" )%>';

iHeight=img1.he ight;
iWidth=img1.wid th;

document.write ("<img src='images/photoblank.jpg' border='1' id='photo'
width=", iWidth, " height=", iHeight, ">");
// alert(document. documentElement .innerHTML);
swapfade(docume nt.getElementBy Id('photo'),'<% =Request.QueryS tring(
"photo" )%>', '1', '');

</script>

_______________ _______________ _______________ ____-

This works 99% of the time - but every so often the image comes up with
width and height = 0 - I am sure that it is due to the image not being fully
loaded before the img1.height line is called.. I have scoured the net on
this and found where I need to make sure the image is complete/loaded before
testing for it's height and width- nothing I have tried has worked yet...

Thanks for your help!
Feb 20 '06 #1
11 1629
Hiya Doug

Have you tried the onload event handler?

You will need to move everything after img1.src = <%..... into a
separate function then set img1.onload to the name of this function.

Something like this

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

<script language="javas cript1.2" type="text/javascript">

var iWidth = 0;
var iHeight = 0;

img1 = new Image();
img1.src = '<%=Request.Que ryString( "photo" )%>';
img1.onload = imgLoaded;

function imgLoaded( anImg ) { //anImg is set automatically.. ..
iHeight=anImg.h eight;
iWidth=anImg.wi dth;

document.write ("<img src='images/photoblank.jpg' border='1'
id='photo'
width=", iWidth, " height=", iHeight, ">");
// alert(document. documentElement .innerHTML);
swapfade(docume nt.getElementBy Id('photo'),'<% =Request.QueryS tring(
"photo" )%>', '1', '');
}
</script>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Is that any good to you?
tihu

Feb 20 '06 #2
DDL
I'll give it a try and report back...THANKS!
"tihu" <ti********@gma il.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
Hiya Doug

Have you tried the onload event handler?

You will need to move everything after img1.src = <%..... into a
separate function then set img1.onload to the name of this function.

Something like this

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

<script language="javas cript1.2" type="text/javascript">

var iWidth = 0;
var iHeight = 0;

img1 = new Image();
img1.src = '<%=Request.Que ryString( "photo" )%>';
img1.onload = imgLoaded;

function imgLoaded( anImg ) { //anImg is set automatically.. ..
iHeight=anImg.h eight;
iWidth=anImg.wi dth;

document.write ("<img src='images/photoblank.jpg' border='1'
id='photo'
width=", iWidth, " height=", iHeight, ">");
// alert(document. documentElement .innerHTML);
swapfade(docume nt.getElementBy Id('photo'),'<% =Request.QueryS tring(
"photo" )%>', '1', '');
}
</script>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Is that any good to you?
tihu

Feb 20 '06 #3
Hiya.

Sorry I made a mistake in my above reply.

The imgLoaded function doesnt get a copy of the image, it receives an
event object.

So the imgLoaded function needs to be

function imgLoaded( event ) {
iHeight=img1.he ight;
iWidth=img1.wid th;

Good luck

Feb 20 '06 #4
DDL
hmm... look over... see anythign amiss? hit the site... not working exactly
right.. not getting the image?

<script language="javas cript1.2" type="text/javascript">

img1 = new Image();
img1.src = '<%=Request.Que ryString( "photo" )%>';
img1.onload = imgLoaded;

function imgLoaded( event ) {
var iWidth = 0;
var iHeight = 0;
iHeight = img1.height;
iWidth = img1.width;

document.write ("<img src='images/photoblank.jpg' border='1' id='photo'
width=", iWidth, " height=", iHeight, ">");
alert(document. documentElement .innerHTML);
swapfade(docume nt.getElementBy Id('photo'),'<% =Request.QueryS tring(
"photo" )%>', '1', '');
}

</script>

"tihu" <ti********@gma il.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hiya.

Sorry I made a mistake in my above reply.

The imgLoaded function doesnt get a copy of the image, it receives an
event object.

So the imgLoaded function needs to be

function imgLoaded( event ) {
iHeight=img1.he ight;
iWidth=img1.wid th;

Good luck

Feb 20 '06 #5
No I don't know.

Would you add alert( "src=" + img1.src + " h=" + img1.height + " w="
img1.width + " ok=") to the imgLoaded func to see whats going on

Feb 20 '06 #6
DDL
This appears to be working!

<script language="javas cript1.2" type="text/javascript">

img1 = new Image();
img1.src = '<%=Request.Que ryString( "photo" )%>';
img1.onLoad = imgLoaded (this);

function imgLoaded( img ) {
var iWidth = 0;
var iHeight = 0;

iHeight = img1.height;
iWidth = img1.width;

document.write ("<img src='images/photoblank.jpg' border='1' id='photo'
width=", iWidth, " height=", iHeight, ">");
// alert(document. documentElement .innerHTML);
swapfade(docume nt.getElementBy Id('photo'),'<% =Request.QueryS tring(
"photo" )%>', '1', '');
}

</script>
Feb 20 '06 #7
DDL
Spoke too soon... seems to be working in IE - not seen it fail - but FIREFOX
fails most times - I get the 0x0 image... ARGH!

"DDL" <dl****@hotmail .com> wrote in message
news:G5******** *************** *******@giganew s.com...
This appears to be working!

<script language="javas cript1.2" type="text/javascript">

img1 = new Image();
img1.src = '<%=Request.Que ryString( "photo" )%>';
img1.onLoad = imgLoaded (this);

function imgLoaded( img ) {
var iWidth = 0;
var iHeight = 0;

iHeight = img1.height;
iWidth = img1.width;

document.write ("<img src='images/photoblank.jpg' border='1' id='photo'
width=", iWidth, " height=", iHeight, ">");
// alert(document. documentElement .innerHTML);
swapfade(docume nt.getElementBy Id('photo'),'<% =Request.QueryS tring(
"photo" )%>', '1', '');
}

</script>

Feb 20 '06 #8
Hmm

Need to change
img1.onLoad = imgLoaded (this);
because this will call the imgLoaded function straight away then set
onload property to the result of the function

Stick with img1.onload = imgLoaded; as this will make the onload
property a reference to the imgLoaded function and call it later

But you've already tried that and it doesnt work properly so now we're
both stuck!

Can you try the alert function to see whats going on in the imgloaded
function

Feb 20 '06 #9
DDL
got this: but the alert never fires... hmmm - I'll add one up front too...

<script type="text/javascript">

img1 = new Image();
img1.src = '/images/family/Image12.jpg';
img1.onLoad = imgLoaded;

function imgLoaded( event ) {
var iWidth = 0;
var iHeight = 0;

iHeight = img1.height;
iWidth = img1.width;
alert( "src=" + img1.src + " h=" + img1.height + " w=" + img1.width )

document.write ("<img src='images/photoblank.jpg' border='1' id='photo'
width=", iWidth, " height=", iHeight, ">");
// alert(document. documentElement .innerHTML);
swapfade(docume nt.getElementBy Id('photo'),'/images/family/Image12.jpg',
'1', '');
}

</script>
Feb 20 '06 #10

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

Similar topics

5
2172
by: Zambien | last post by:
Hi all, Here's my problem. I have tables that are using the menu/submenu idea for hiding rows. This works fine in IE (of course) and does show/hide correctly in netscape, but as soon as the shown method is called, the table gets skewed and the presentation of the data on the page goes horribly wrong. I don't think this is a table issue as I have spent alot of time staring at this code. Here is the html...
5
2985
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig <<<<<<<<<<<<<<CODE>>>>>>>>>>>>>>>> <html>
1
1338
by: KitKat | last post by:
With the help of kind, brilliant folks, I have been working on this program that uses a combo box selection to display six different jpgs. The jps are a time stamp, and the files are located in six different folders of camera views. HOWEVER, some of these folders do not have that certain timed jpg. So...I need to figure out how to show all the rest of the pictures and use an "no image available or something" for the program to work...
5
1452
by: Ed Jay | last post by:
I have a switch statement that controls which of several containers is displayed or not. It currently looks like: function showHelp(n) { show('vhelp'); //makes parent container visible switch (n){ case 0: show('image0');hide('image1');hide('image2');...;hide('imagem'); break; ..
2
2360
by: Poppa Pimp | last post by:
ImageResizer.php Image Resizer PLEASE HELP The URL of the page this is on in my site is http://poppa-pimps-wallpapers.com//ImageResizer.php You can click on browse and get image,but when you upload image it will go to another page and says ]((unable to create emp directory)) Here is a site to be able to see script actually work http://tech.tailoredweb.com/image-editor-52/ and can be DL from there also. I am using FP 2003 and...
36
3095
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it highlights this line: <form name="frmCurrency" action="" method="post"> Page source....
7
3923
by: webgyrl | last post by:
Hi, I am helping a musician friend of mine with his profile and I found a cool layout on Nas' MySpace page. I changed some things and re-did the graphics and I basically popped my Image URLS where the ones were in Nas' profile code. Something strange is happening tho. When I try to preview the layout, the entire profile is all covered up. My images show, but all the other elements have disappeared. I am not sure where in the CSS I...
0
1901
by: magicofureyes | last post by:
Hello Guys im a just a new user and i dnt knw much abt Xml i want to upload a new template in Blogger so got some free coding but when i save this code in Blogger template it say '''' Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The element type "Variable" must be terminated by the matching end-tag "". so please help me out and check this coding if...
5
1403
by: katie smith | last post by:
Here is the program I just started, The problem i am having is I'm trying to get it to load the image file Sand1 with eval(loader) = pygame.image.load(loader) because Loader is euqual to "Sand1" but It wont load it. If I set it as loader = pygame.image.load(loader) then it sets the image to the variable loader. So I'm basically trying to set a string equal to a surface variable. I dont want to have to go Sand1 = pygame.image.load("Sand1.bmp")...
0
8376
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
8290
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
8594
tracyyun
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...
0
7307
agi2029
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...
0
5622
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
4149
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
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
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
2
1596
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.