/    Sign up×
Community /Pin to ProfileBookmark

varible problems

Ive got some preloading image code similar to this,

image1=new Image
image1.src=”picture1.bmp”
image2=new Image
image2.src=”picture2.bmp”

but i need to use a varible in the code like this:

image1″ + varible + “=new Image
image1″ + varible + “.src=”picture1.bmp”
image2″ + varible + “=new Image
image2″ + varible + “.src=”picture2.bmp”

how would i do this?

also i have a <div> that has some text in it and a link on the whole <div> how do i make it so the link goes for the whole <div> and not just the length of the text with out using the css background color tag?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@BillyRayAug 25.2004 — Something like this should work:

window['image1' + variable] = new Image();
window['image1' + variable].src = 'picture1.bmp';

As for the A tag, I've not tried this, but try setting the display property to "block":

&lt;a href="xyz.html" style="display:block;"&gt;...&lt;/a&gt;
Hope this helps,

Dan
Copy linkTweet thisAlerts:
@ck_net_2004authorAug 25.2004 — Thanks i'll try that when i get back to my home pc,

i have been designing a in window window, it looks & reacts like a normal window, but when opening multiple ones of these windows i couldn't get around making different id's for the close buttons and scince theres 2 designs i have that can be selected from when opening the window all the windows close buttons looked the same which stuffed up the entire thing.
Copy linkTweet thisAlerts:
@ck_net_2004authorAug 25.2004 — 1 more thing how can i get an entire <div> to be on top of everything when clicked with something like a onclick?
Copy linkTweet thisAlerts:
@KorAug 25.2004 — You may use event handlers inside your div tags, so:

<div style="cursor:hand;width:150" onclick="window.open('yourlink.html')"><a href="yourlink.html">link</a></div>

The problem is that Mozilla based on browsers will not see the cursor as a hand (this is a CSS IE only attribute), even if they will open the link onclick.
Copy linkTweet thisAlerts:
@BillyRayAug 25.2004 — Using "cursor:pointer" instead of "cursor:hand" works in all browsers, including IE.

Dan
Copy linkTweet thisAlerts:
@KorAug 25.2004 — Tx,good point, never know about it... there is always something new to learn ?
×

Success!

Help @ck_net_2004 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 6.15,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...