473,324 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

how to get swf/image width/height with javascript

Mike Kypriotis
in php with getimagesize() for both img and swf worked well,in javascript?
PS I do not want to first load it and then use its id as a reference object, I want to know because I need to know in order to display it, (so use say the relative path as an argument to whatever works)
Apr 26 '11 #1
5 4167
Dormilich
8,658 Expert Mod 8TB
you can’t determine an image’s size without downloading it. You may of course load it in the background without attaching it to the document tree.

To get the size of the image you can then use the naturalWidth/naturalHeight property of the image object, although that is not supported in every browser.
Apr 27 '11 #2
height/width properties also work, problem is I want to do the same with swf files and do not work for images I use
Expand|Select|Wrap|Line Numbers
  1. var img = new Image();
is there something more generic than Image() like object() which can accept swf?
Apr 27 '11 #3
Dormilich
8,658 Expert Mod 8TB
If I remeber right, an SWF file is used with the <object> tag, i.e. document.createElement("object");
Apr 27 '11 #4
in the new Image() way of thinking tried
Expand|Select|Wrap|Line Numbers
  1. var a=document.createElement("object"); 
  2. a.src="test.swf";
  3. var height = a.height;
  4. var width = a.width;
  5. alert ('The swf size is '+width+'*'+height);
  6.  
hoping that once the src was set I could retrieve the dimension but didn't worked
Apr 27 '11 #5
Dormilich
8,658 Expert Mod 8TB
hoping that once the src was set I could retrieve the dimension but didn't worked
obviously, the <object> element does not have a src attribute (an <object>’s source is defined in one of its <param> child elements)
Apr 27 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: ok | last post by:
Hello, Q: How do I get image width and height before uploading an image? This because, I want to restrict people uploading huge files. Thanks in advance
7
by: Premshree Pillai | last post by:
Hello, Is there a Py module available using which I can find the width and height of any image format? -Premshree ===== -Premshree http://www.qiksearch.com/]
2
by: Roger Withnell | last post by:
I browse for an image using form input type file and call a JavaScript function with onchange. I then want the function to check the image's properties (width, height, filesize). In WinIE,...
4
by: Doug van Vianen | last post by:
Hi, I have the following coding on a web page. It causes two pictures (pic1.jpg and pic2.jpg) to show, one above the other and then when one clicks on the top picture is squeezes to the left...
10
by: News | last post by:
I am trying to be able to manipulate the width and height of an <img> but do not seem to be able. "Yes", I know the JavaScript will "not" manip anything, which is ok. I simply do not know how to...
1
by: emilmgeorge | last post by:
Pls somebody give me the code for getting the height and width of a image in pixels in javascript or asp. Thanks - Emil
7
by: finecur | last post by:
I have a <img scr="mypic.jpg"in my html. I would like to display the image by width=200 if the image width is larger than 200. I also would like to display the image by its real width if the image...
2
by: Atul | last post by:
I am unable to find image height and width in mozilla firefox. My code is working in IE but not in Mozilla. How can i find image width and height in mozilla? function check(sel) { if(sel != "")...
1
epots9
by: epots9 | last post by:
I have a image inside of a div <div id="image"> <div id="loader"> <img id="loaderImage" src="assets/loader.gif" alt="loading..." /> </div> <div id="loaded"> <img id="picture" src="" alt=""...
1
by: fraser5002 | last post by:
Hi I have a problem with the code im using to resize an image to fit it within a fixed size cell in a table. The code is supposed to resize the image and retain its aspect ratio. But it does not...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.