PDA

View Full Version : Getting Height and Width values for images


Mikeb
12-May-2003, 04:07 PM
Hi,

I'm customising the 'Extended Info' link. What I want to do is to dynamically make the pop-up window for extended product info the same size (or marginally bigger) than the size of the product image which is to be viewed. I've got it working apart from one snag.

NETQUOTVAR:IMAGEWIDTH and NETQUOTVAR:IMAGEHEIGHT contain both the size of the image and the following text: "Width=" and "Height="! Is there a way to separate the actual height and width values from the Actinic variables?

cheers,

Mike:confused:

NormanRouxel
12-May-2003, 04:31 PM
One way is to use some JavaScript to separate out the bits you want:-

i.e.


in your call to the popup replace NETQUOTEVAR:IMAGEWIDTH

with

'NETQUOTEVAR:IMAGEWIDTH'.match(/\d+/)

and similarly for

'NETQUOTEVAR:IMAGEHEIGHT'.match(/\d+/)



This strips out all non numerics from the string.

Norman

Mikeb
12-May-2003, 04:42 PM
Thank you Norman. Unfortunately my JavaScript ain't the best. The current line looks like this:

<A HREF="javascript:ShowPopUp('P_info_NETQUOTEVAR:PRODUCTREF.html',500,600);">See More!</A>

Can I just plonk your code in to replace '500' and '600', or do I need to parse the variables, pass them to new variable and then plonk them in?

cheers,

Mike

NormanRouxel
13-May-2003, 12:10 AM
Just plonk them in (single quotes and all) and see what happens.

By the way - a great way of diagnosing JavaScript is to bung in an alert() statement. For example

changing your line to be

<A HREF="javascript:alert('NETQUOTEVAR:IMAGEWIDTH'.match(/\d+/));ShowPopUp('P_info_NETQUOTEVAR:PRODUCTREF.html',500,600);">See More!</A>

Warning. JavaScript should be single word with no space in the middle above.

Would let you see what the bit of code generates before calling the popup routine.

Norman

Mikeb
13-May-2003, 10:00 AM
Thank's Norman. That's working a treat! I was able to further edit the actinicextras.js file in the root of the server to allow me to take off the scrollbars. Now my pop-up window automatically re-sizes to the product image size (+ enough height to allow for the 'close window' message) and appears without scrollbars,

your a genius!

cheers,

Mike :-)