Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Issue with loading image in Mac/Safai

Posted on 2007-11-27
11
Medium Priority
?
548 Views
Last Modified: 2013-12-07
I am unable to load image in Safari browser with Mac OS. The same is loaded perfectly fine in IE, Firefox browsers in Windows and Mac OS.
The javascript line which is failing is

this.oImage = new Image;

Thanks



0
Comment
Question by:RNK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 7

Expert Comment

by:Maverick_Cool
ID: 20359780
First check what object does this refer in these browsers
0
 

Author Comment

by:RNK
ID: 20359868
The Image object should be HTMLImageElement
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20360286
Are you able to give an example?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:nizsmo
ID: 20360293
0
 

Author Comment

by:RNK
ID: 20369354
var newImg = new Image();
newImg.src = src;
Img.width = newImg.width;
Img.height = newImg.height;

Img.src = src;

does not seem to be assigning the height and width correctly
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 336 total points
ID: 20369708
Where does your Img variable come from? is it an ID from the image tag? eg if you have something like this:
<img id="test_image" src="..." ....>

you can do something like this in javascript:
var newImg = new Image();
test_img = document.getElementById('test_image');
newImg.src = src;
test_img.width = newImg.width;
test_img.height = newImg.height;

test_img.src = src;


hope this helps.
0
 
LVL 7

Assisted Solution

by:Maverick_Cool
Maverick_Cool earned 332 total points
ID: 20371771
use <object>.style.width instead <object>.width.

style has more effect/precedence
0
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 332 total points
ID: 20374286
Some browsers executes the next statement after src= immediately so the height and width is not available
Some older browsers cannot change the size of a rendered image

try this:


var Img = null; // global var
function resizeIt() {
  Img.width = this.width;
  Img.height = this.height;
  Img.src = this.src;
}

function loadImage(theImg,src) {
  Img = theImg;
  var newImg = new Image();
  newImg.onload=resizeIt;
  newImg.src = src;
}


0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20374299
and call it like

<a href="#"
onClick="loadImage(document.getElementById('img1'),'test.jpg'); return false">Load</a>
<img src="dummy.jpg" id="img1">
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21447817
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
This article outlines the struggles that Macs encounter in Windows-dominated workplace environments – and what Mac users can do to improve their network connectivity and remain productive.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question