/    Sign up×
Community /Pin to ProfileBookmark

Problems in browsers with Image name

Hi Guys,

I have a Div that has a background image set dynamically and it works pretty much most of the time.

[code]
<div id=”Image1″ style=”background-image:url(<%=strImage%>) no-repeat;”>
[/code]

But when an image with a name similar to img(1).jpg gets used only some browsers load the image and I can only thinks its the brackets in the name of the image.

Firefox wont load it and only some pc’s with IE load it.

Can anyone suggest a way round this as I cant stop the brackets () in some of the images.

to post a comment
CSS

19 Comments(s)

Copy linkTweet thisAlerts:
@CharlesMar 09.2009 — You want to URL encode your URLs server side. It's likely that your scripting language has a built in function for this but [font=monospace]image(1).jpg[/font] would become [font=monospace]image&#37;281%29.jpg[/font].
Copy linkTweet thisAlerts:
@FangMar 09.2009 — As a string &lt;div id="Image1" style="background-image:url([COLOR="Blue"]'[/COLOR]&lt;&amp;#37;=strImage%&gt;[COLOR="Blue"]'[/COLOR]) no-repeat;"&gt;
Copy linkTweet thisAlerts:
@TagUK2006authorMar 09.2009 — Thank you guys... done both and is working well now.. :-)
Copy linkTweet thisAlerts:
@CharlesMar 09.2009 — You don't need to do both and Mr. Fang's suggestion will have fewer bad side effects.
Copy linkTweet thisAlerts:
@TagUK2006authorMar 11.2009 — Hi Guys,

Im still having problems with this ..

I have people tell me they cant see the top banner??

Ive loaded it correctly as far as i see and wondered if you guys can tell me if you see a banner here http://kennels.jajca.co.uk

The Div code is like this for it

<i>
</i>&lt;div id="banner" style="background-image: url('&lt;&amp;#37;=strBanner%&gt;');background-repeat:no-repeat; background-position: left top;" border="0" cellspacing="0" cellpadding="0"&gt;


Thoughts appreciated

:-)
Copy linkTweet thisAlerts:
@FangMar 11.2009 — For div ?? [I]border="0" cellspacing="0" cellpadding="0"[/I]

Which browsers are not seeing the banner?
Copy linkTweet thisAlerts:
@TagUK2006authorMar 11.2009 — Hi Fang,

The lady that is having bother says she has used IE and Firefox.

I did think she was joking with me but she claims to see no banner on the page no matter what I try.

Did you see it in the link?

Thanks

Tag
Copy linkTweet thisAlerts:
@FangMar 11.2009 — No problems with the image.
Copy linkTweet thisAlerts:
@web-designMar 11.2009 — I don't see any problems either but you should take Fang's advice and remove the [I]border="0" cellspacing="0" cellpadding="0"[/I] from the <div> element. Those attributes don't apply to divs.
Copy linkTweet thisAlerts:
@FangMar 11.2009 — Repeat: Which browsers and OS are giving the problem?

Remove this: [I]border="0" cellspacing="0" cellpadding="0"[/I] from the div
Copy linkTweet thisAlerts:
@TagUK2006authorMar 12.2009 — Hi Fang,

Sorry for the delay I was away all evening,

I just used the cellspacing="0" cellpadding="0" as a panic measure as I was stumped and was giving anything a go..as you see on the first post that all i had inline wes this.

<i>
</i>&lt;div id="Image1" style="background-image:url(&lt;&amp;#37;=strImage%&gt;) no-repeat;"&gt;


As suggested i put ' ' round my string Var as some images were not showing and this did it for everyone except 1 user who claims to have tried in IE7 & Firefox and uses XP

Now I have asked everyone i know to look and all say they see the banner with no problems.

The user with the issues says she recently formatted her drive but has been for all MS updates but im wondering if she could have IE6 or lower and im not to sure if the background-image:URL works on older browsers?

But all other browsers that were not seeing that banner did so when I added the single quotes ('<%=strImage%>')

Im stumped to be honest.

Thanks again

Tag :-)
Copy linkTweet thisAlerts:
@FangMar 12.2009 — Background-image works in older browsers, although you should use just [I]background[/I] as you are also using repeat.
&lt;div id="Image1" style="background:#000 url('&lt;&amp;#37;=strImage%&gt;') no-repeat;"&gt;
Copy linkTweet thisAlerts:
@TagUK2006authorMar 12.2009 — Thanks Fang, I will give that a try, I did have a go at that to as was following examples on tutorial info sites..

Could there be something wrong or a setting that would block Div backgrounds in their browser?

Thanks again

Tag :-)
Copy linkTweet thisAlerts:
@FangMar 13.2009 — It is possible to block images, but then all images would be blocked.
Copy linkTweet thisAlerts:
@TagUK2006authorMar 13.2009 — Hi Fang, that was my understanding but wasnt sure if Div backgrounds had any different deactivatirs,

Im starting to think im being wound up a little but you never know.

The lady who cant see the banners is the site owner so poses a problem for me?? She can see the banners on her laptop but not on her main PC

It doesnt make sence for sure...

Are there any other ways I can load a dynamic image into a Div Background?

Thanks again

Tag :-)
Copy linkTweet thisAlerts:
@FangMar 13.2009 — It's possible the browser is retrieving an old document from the cache. Tell her to press Ctrl-F5
Copy linkTweet thisAlerts:
@TagUK2006authorMar 13.2009 — Well Im stumped??

What would you do in this situation Fang? I did get her to clear all her cookies and history...

Is there a site check board in this forum to see if anyone else doesnt see it ?

Thanks again

Tag :-)
Copy linkTweet thisAlerts:
@FangMar 13.2009 — I would personally check her browser.
Copy linkTweet thisAlerts:
@TagUK2006authorMar 13.2009 — Thanks Fang,

I will try to get her to the MS update site, Im about 500 miles away from her and mesengers remote assistance doesnt seem to work between us.

Thanks for all your suggestions

Regards

Tag :-)
×

Success!

Help @TagUK2006 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 5.16,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...