You are here: Re: Img Tag Attributes Not Being Set (Namely .width and .height) (HERE'S THE CODE... : ) ) « HTML « IT news, forums, messages
Re: Img Tag Attributes Not Being Set (Namely .width and .height) (HERE'S THE CODE... : ) )

Posted by Nonee on 10/18/04 11:30

Ok, here is the code. I also included a func that tries to fix the
window after the window is fully loaded. The func is called but it
still doesn't work. Btw, the a = and x = is to get the image name
from the thumbnail name... aka tnImage to Image.

PLEASE HELP..... heh.

Thanks...

var anImage = new Image();

function BlowUp(filename)
{
// var filename;
var a,x;
var winHeight, winWidth;

a = filename.indexOf('thumbs');
x = filename.substring(0,a) +
filename.substring(a+9,filename.length);
// ../images/urns/thumbs/tnblack engraved.jpg
anImage.src = x;

// Get Name of Item
a = filename.indexOf('tn');
x = filename.indexOf('.jpg');
name = filename.substring(a+2,x);


winHeight = anImage.height+150;
winWidth = anImage.width+100;

// To center the image (and page) on the screen
var winl = (screen.width - winWidth) / 2;
var wint = (screen.height - winHeight) / 2;
var winproperty =
'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,width='+winWidth+',height='+winHeight+',top='+wint+',left='+winl+',resizable=0';

var win = window.open("", "win", winproperty); // a window
object
var generator = win.document;
var root = "";

generator.open("text/html", "replace");

generator.write('<html>');
generator.write('<head>');
generator.write('<title>'+name+'</title>');
generator.write('<link href="'+root+'/css/style.css"
rel="stylesheet" type="text/css">');
generator.write('<link href="'+root+'/css/format.css"
rel="stylesheet" type="text/css">');
generator.write('<script>');
generator.write(' function FixWindow()');
generator.write(' {');
generator.write(' var winHeight =
document.images[0].height+200;');
generator.write(' var winWidth =
document.images[0].width+100;');
generator.write(' var winl = (screen.width -
winWidth) / 2;');
generator.write(' var wint = (screen.height -
winHeight) / 2;');
generator.write(' window.moveTo (winl,wint);');
generator.write(' window.resizeTo
(winWidth,winHeight); ');
generator.write(' }');
generator.write('</script>');
generator.write('</head>');
generator.write('<body onLoad="focus(); FixWindow();"
leftmargin="0" topmargin="0">');
generator.write('<table width="100%" border="0">');
generator.write(' <tr>');
generator.write(' <td><p>&nbsp;</p><div
align="center"><span class="Header"><strong>'+name+'</strong><br><img
src=" ' + anImage.src + '" alt="Close this window to return"
border="1"></div></td>');
generator.write(' </tr>');
generator.write(' <tr>');
generator.write(' <td><div align="center"><font
color="#000000">Close This Window To
Return.</span></font></div></td>');
generator.write(' </tr>');
generator.write('</table>');
generator.write('</body>');
generator.write('</html>');

generator.close();

}

On 27 Oct 2005 00:44:02 -0700, hywel.jenkins@gmail.com wrote:

>
>Nonee wrote:
>> On Thu, 27 Oct 2005 01:05:19 GMT, mbstevens
>> <NOXwebmasterx@xmbstevensx.com> wrote:
>>
>> >mbstevens wrote:
>> >> Nonee wrote:
>> >>
>> >>> Remember, the image and the window are both dynamic
>> >
>> >Or, if you're saying that the image is actually being created on the
>> >fly, then you (probably) have server side privileges, and you should be
>> >able to determine the width and height in software before you create the
>> >popup.
>
>> Bascially, the page I am creating has a list of products. The new
>> popup window is a larger size of the image. There is approx 100
>> different images so I could do a lookup table but there has to be a
>> better way. Is there any way to force the browser to load the image
>> and set the img attributes?
>
>Show us the code! Show us the code!
>
>You can more than likely use server-side code to determine the size of
>the image just before you write out the link that the user has to click
>to open the window. You can then use those dimensions to populate the
>window.open function.
>
>Still, without the code, people might continue to guess the solution to
>your problem, but they'll eventually give up because they'll realise
>that you're not really listening.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация