/    Sign up×
Community /Pin to ProfileBookmark

Safari conflict wit Width and Height

Can anyone tell me why Safari isn’t finding the width and height of my image.

External Javascript:

function cmdOpenWindow(image,subfolder){
var img = new Image();
var imgPath = “../Images/”;
imgPath = imgPath + subfolder + “/” + image;
imgPath = imgPath + image;
img.src = imgPath;
var width = [COLOR=”Red”]img.width[/COLOR] + 70;
var height = [COLOR=”red”]img.height [/COLOR]+ 90;
window.open(“/Pages/Images.asp?strImage=”+image+”&strSubfolder=”+subfolder, “_blank”, “toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=”+width+”, height=”+height);


<img class=”ImageOpen” src=”../Images/Folder1/tTheTeam.jpg” alt=”” height=”54″ width=”72″ border=”0″ onclick=”cmdOpenWindow(‘TheTeam.jpg’,’Folder1′)” />

to post a comment

2 Comments(s)

Copy linkTweet thisAlerts:
@Arty_EffemSep 08.2007 — Can anyone tell me why Safari isn't finding the width and height of my image.
Because the image hasn't loaded at the time it's dimensions are being read. You need to use the image's onload event, either to trigger the reading of its dimensions or to set a flag that indicates that they can be read.
Copy linkTweet thisAlerts:
@nbcrockettauthorSep 08.2007 — How would you trigger the image's onload event so that it would be able to retreive those dimensions?


Help @nbcrockett spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 2.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ

legal: ({
terms: of use,
privacy: policy
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
recent_tips: (
tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,

tipper: @neststayhome,
tipped: article
amount: 1000 SATS,