kuran Posted May 11, 2006 Share Posted May 11, 2006 hi... need some more help, I just can't get my head around javascript..I'm trying to have a row of links, that when pressed, load a centered (or tiled, if centered isn't possible) .jpg image as the background of that same site.Is this hard to do?Thanks in advance for any help! Link to comment Share on other sites More sharing options...
scott100 Posted May 11, 2006 Share Posted May 11, 2006 Found by google: http://www.codebelly.com/javascript/backimagechange.html Link to comment Share on other sites More sharing options...
MISIIM Posted May 11, 2006 Share Posted May 11, 2006 CSS:body {background-repeat:no-repeat;background-position:center;} Link to comment Share on other sites More sharing options...
aspnetguy Posted May 11, 2006 Share Posted May 11, 2006 <html><head><title></title><script type="text/javascript">function changeBg(img){ var bodyObject = document.getElementsByTagName('body')[0]; bodyObject.style.backgroundImage = 'url(' + img + ')'; bodyObject.style.backgroundRepeat = 'no-repeat'; bodyObject.style.backgroundPosition = 'center';}</script></head><body><a href="javascript:changeBg('bgOne.jpg')">One</a><a href="javascript:changeBg('bgTwo.jpg')">Two</a><a href="javascript:changeBg('bgThree.jpg')">Three</a></body></html> Link to comment Share on other sites More sharing options...
kuran Posted May 13, 2006 Author Share Posted May 13, 2006 thanks everyone! Link to comment Share on other sites More sharing options...
kuran Posted May 13, 2006 Author Share Posted May 13, 2006 I have one more problem... When I view the site in Firefox, the image is only centered horizontally, not vertically!However in Safari on my Mac, it is displayed fully centered, as it should be.This is the site in question: http://www.wimtubbax.be/photography06/Is there anything I can do to fix this?Thanks in advance! Link to comment Share on other sites More sharing options...
scott100 Posted May 13, 2006 Share Posted May 13, 2006 It looks fine in my IE, FF and Opera on windows.Maybe it's a mac thing... Link to comment Share on other sites More sharing options...
kuran Posted May 13, 2006 Author Share Posted May 13, 2006 It looks fine in my IE, FF and Opera on windows.Maybe it's a mac thing...<{POST_SNAPBACK}> Well I tried it when booted in Windows also... (I have an intel Mac)Is it centered vertically for you? It just 'sticks' to the top of the screen when I try it in Firefox... Link to comment Share on other sites More sharing options...
scott100 Posted May 13, 2006 Share Posted May 13, 2006 Is it centered vertically for you? It just 'sticks' to the top of the screen when I try it in Firefox...<{POST_SNAPBACK}> Yes it works fine for me, if you click on disorder06.jpg it's perfectly centered. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now