Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    JavaScript


Advertisements:










DIV Background-image Swap


I am trying to get an background image to change to another image.

Here is my code below:

Code:


View 1 Replies (Posted: May 17, 2004, 13:59)

Sponsored Links:

Related Forum Messages For JavaScript category:
Image Swap In Firefox - Change The Background Image Of A Button When The Mouse Is Hovered
I'm trying to change the background image of a button when the mouse is hovered. with the statement

function testIn ()
{
elem.style.backgroundImage = 'url("image_name_in.png")';
}
function testOut ()
{
elem.style.backgroundImage = 'url("image_name_out.png")';
}

i'm doing this with onMouseOver=testIn() and onMouseOut=testOut(). Here the problem is that, when i hover the mouse. I'm seeing the progress bar (bottom right side) is shown in firefox as if some page is getting loaded

Posted: Feb 4 11 at 18:29

View 3 Replies!   View Related
Swap Background Image On Iframe Load?
I'm trying to swap the background image of my index page logo div when a document is loaded into an Iframe on the index page. This is what I have so far in the external js of the page loaded to the Iframe. The function is called in the window onload of the same js file but it makes the logo image turn blank. The alert declares 'silver jewelry' and the image I want to replace the logo is named 'silver jewelry.jpg'

Code:
var logo=top.document.getElementById('logo');
alert(document.title);
function changelogo(){var title=document.title;logo.style.background='url(../sources/'+title+'.jpg)';}

Posted: Jan 2, 2010

View 7 Replies!   View Related
Background Image Swap Not Working In Safari
I have a snippet of code that swaps a background image when a link is clicked and swaps the image back to the original when clicked again. This works perfectly in IE and Firefox (both PC and MAC) but doesn't work in Safari. In safari it works on the first click and the first swap back then it stops working.

[Code]....

Posted: 05-30-2010, 10:47 AM

View 2 Replies!   View Related
Image Swap By Thumbnails When In A Cell Background?
Looking for javascript, to do what i've hap-hazardly slapped together here: I'd like to do this without having to reload a page or create a new page for each image.

[URL]

Specifically the switching of the main image by the thumbnails. The difference in what i've seen online, is that i'm actually using them as a cell background.

Posted: 02-14-2011, 05:54 PM

View 1 Replies!   View Related
JQuery :: Css - Swap BackgroundColor For Background Image?
uses this jquery code:

.css({ backgroundColor: '#ddd' })

Instead, i'd like to use a background image. How do I change the jquery code to do that?

I'm wanting to do something like

.css({ backgroundImg: 'images/newsletter-dropdown.jpg' })

Posted: May 5 10 at 5:16

View 1 Replies!   View Related
JQuery :: Background Image Swap On Hover Over Different Link
I'm trying to achieve an effect where background image will change once you hover over a different link, but not sure how to go about that...Here's what I got:

HTML
<ul id = "list">
<li id="home"><a href="#">HOME</li></a>
<li id="about"><a href="#">ABOUT</li>
<li><a href="#">PORTFOLIO</li>
<li><a href="#">WORK</li>
<li><a href="#">CONTACT</li>
<li><a href="#">GET A QUOTE</li>
</ul>

CSS
body {
background-image: url(Images/home.jpg);
} ul li {
list-style-type:none;
font-size:36px;
font-family:Impact, Charcoal, sans-serif;
} a:hover {
background-color:#7EB6FF;
-moz-border-radius: 15px;
border-radius: 5px;
width:40px;
} a:link {
text-decoration:none;
}

And JS should probably go something like this:
$("#about").hover(function() {
$(this).css("background-image", "url('Images/about.jpg')");
});

Though this only leads to image being show only partially (given that its li element only, I suppose).

Posted: 07-Dec-2011

View 5 Replies!   View Related
Swap A Background Image On Page Refresh Using Localhost?
I need to be able to swap a background image on page refresh. I am attempting to do this with javascript and I'm referencing the id I have set for the body of the page. Here is what I have come up with so far and it doesn't seem to be working:

<script type="text/javascript">
window.onload = choosePic;
function choosePic() {

[code].....

Posted: Apr 3 11 at 20:01

View 2 Replies!   View Related
JQuery :: Hover Image Swap - Mouse Over The Thumb Image Should Change The Lower Image Accordingly
I have been attempting to implement the JQuery Hover Implementation for a page that now uses JavaScript. mousing over the Thumb Image should change the Lower Image accordingly, and when you mouse out the background-color should return to the background color #FFFFFF. Here is my JSFiddle: [URL] Here is the link to the site which illustrates the behavior: [URL]

Posted: Apr 28 11 at 17:41

View 2 Replies!   View Related
Swap URL On Image Swap
I am a complete novice with Javascript, but am trying to work out how I can get a button to swap to another image when clicked, and each image have a different URL attached. I want to use this to toggle the bgcolor of my page using this script:

Code:
<script type="text/javascript">
<!--
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
[Code]...

Posted: 03-28-2011, 12:18 PM

View 1 Replies!   View Related
JQuery :: Assign The Correct Class To An Image In An Image Swap Gallery
So, I'm using this lovely image swap fellow: jQuery Image Swap Gallery You can see a demo of it in action on my site here: [URL] The problem is, with the #main_image img

<div id="main_image" class="grid_7">
<img class="wide" src="zImages/arrows-2.jpg" />
</div>

note the class="wide". there are two classes that need to be applied dynamically to the images, once they're "swapped": "wide" and "tall", based on whether we're using an image that is in portrait or landscape. The nice thing, which I have a hunch that a superior coder could make use of, is that the thumbnails for each image already have the correct class assigned to them:

[Code]....

Posted: Sep 7 11 at 13:55

View 2 Replies!   View Related
Jquery :: Getting A Relative Path For An Image Swap (not The Rollover Image)
I am trying to replace an image when a link in another part of the page is rolled over. I have a hard coded version working, but I would like to get this so that when I upload to a server I do not need to go in and change the path part.

$(document).ready(function() {
$('.laundryLinks li a').hover(function() {
$('.homeLaundryPict').attr('src', 'http://192.168.1.2:8888/karenMaezenMiller/wp-content/themes/karenMillerTheme/i/laundryHome_quote.jpg'); },
function() {
$('.homeLaundryPict').attr('src', 'http://192.168.1.2:8888/karenMaezenMiller/wp-content/themes/karenMillerTheme/i/laundryHome_noQuote.jpg'); });
});

PS. I also played with trying to just replace a bit of source but had no luck $(this).src.replace("_quote","_noQuote");

Posted: Feb 7 10 at 20:30

View 3 Replies!   View Related
Nesting Onclick Image Swap Events And Image Mapping
I am trying to make a point and click javascript game. Basically what I want is to have one image displayed on screen at the start (room1.jpg). When you click on a door on that image, I have an onclick event to change the image to a new one that shows the door open (room1_a.jpg). What I want is that when you click the now open door, to display the next room in the game. The only solution I can think of is some sort of nested onclick event using several image maps, but I am fairly new to Javascript and I am not sure if that is possible. What it all comes down to is I want to display each incarnation of each room in the game in the same window without having to reload a new window for each room. I hope that makes sense, if not I can try and clarify. Below is the code I have so far. And as you can see all that does is display the open door when you click on the image. I have not done any of the image mapping yet.

[Code]...

Posted: 07-24-2009, 06:00 PM

View 2 Replies!   View Related
Image Swap - Thumbnail The Larger Image Will Go Into The Viewing Area
I am trying to put together a purse shopping site - I would like to have the various views of the same purse in thumbnails under one image then when the customer clicks on the thumbnail the larger image will go into the viewing area. The general layout is like this page - [URL] So when someone clicks on the smallest image I would like it to replace the other image on the page and the larger image becomes the thumbnail. How is this accomplished?

Posted: Jan 14, 2009

View 2 Replies!   View Related
Image Swap OnClick Opens Image In Parent Window
I'm trying to use javascript to load an image on a webpage when another image is clicked on, just like an image gallery and just like this except I don't need any text: [URL] I copied the example above but when I click on the smaller image to load the larger one it works for a fraction of a second (I can see the image load in the right spot), but then the browser goes to the URL of the image instead (showing it on a blank page).

[Code]....

Posted: 07-26-2010, 03:58 PM

View 13 Replies!   View Related
Text Swap - Change Each Image To Different Image On Mouseover
I'm failing to get a pure CSS way to achieve this, so trying JS. Several small images in a row, each different. Want mouseover to:

1. change each image to different image on mouseover (each image has its own mouseover image version).

2. produce different paragraph of text below row of images on each mouseover.

I can achieve it with mouseover on text links or on an image, but not with the two events, viz mouseover image swap + mouseover text swap. Would also want to be able to style the text.

Posted: June 15th, 2010, 07:17 PM

View 4 Replies!   View Related
Swap Image On Click Then Resets When Selecting Next Image
I have four links that use graphics to create an unvisited and visited state (using CSS). The link actually changes a section of text elsewhere on that page, so the user doesn't leave the page. The clicked, visited graphic reflects what text you are reading. You can then select a different link, and new text reflects the link you clicked on. What goes wrong is that if you click all four links, you eventually get all four visited graphics showing.

What I want is this. You click on the graphic and the graphic changes to visited. You then select a different link and that state goes to visited but the previous link that is visited too, changes back to unvisited. Therefore when you click on any link, that visited state is shown, and all others always reset to unvisited. The results is that the visited graphic reflects the current text on that page.

Posted: 01-14-2010, 05:31 PM

View 5 Replies!   View Related
Swap An Image To A Small Area Of A Larger Image?
I have an image showing 42 classmates from 1958. I want to map each small face and replace it with a current portrait on a mouse rollover. The swapimage code works ok, but the new portrait is the size of the original complete image.

<area shape="rect" coords="72,260,143,346" href="#" onMouseOver="MM_swapImage('Image1','','../LoisS.jpg',1)" alt="" onMouseOut="MM_swapImgRestore()">

How can I get the small image to stay small and overlay only the original face, leaving the original large image in place behind it? Can I somehow amend the code above? [I'm no good at writing my own js or css].

Posted: Mar 20 11 at 18:56

View 1 Replies!   View Related
Swap Image And Show Image Zoom
I have a website using BigCommerce that has a feature on the product page that displays some thumbnail images. When a user clicks on a thumbnail image, it shows some description for that image and should also swap the main image on the left to the large version of the selected thumbnail.

The script is doing the show/hide part correctly for the description but isn't swapping the main image. Contacted BigCommerce but they say it's a template specific issue that they can't help with. On checking web inspector, it says that there is an uncaught type error and that the 'largeimage' attribute for the rel tag is missing. I tried adding this back in, but it didn't have any effect. [URL]

Posted: Oct 31 at 10:20

View 1 Replies!   View Related
Place A Background Image Above Body's Background Image?
I have set a background image in body and in .wrap. My question is how do I place a background above all them? It is done with CSS however I didn't figure it yet.

I place all my code in [URL]

<body>
<div class="wrap">
</div>
</body>

Posted: Oct 31 11 at 8:39

View 2 Replies!   View Related
Image Swap
I am looking to find a javascript that image swaps 4 button images that are to be used as links.

There will be an unvisited button (color of my choice)

There will be a hover state which Is green.

There will be a visited link button that is purple.

There will be a currently active page button that will be red.

I have a script that works for 3 of the for states.
The script that I have also will not keep the purple, visited state, as standard text based links will when a page has allready been visited.
Does anyone have a script that will work for what I want to do for all states.

I don't know how to build a script of my own, but plan on learning.

Does anyone have a script that will work for what I want to do for all 4 link/swap states that I want incorporated?

Posted: Nov 17, 2007, 15:38

View 7 Replies!   View Related
Image Swap - Capturing File Name Rather Than The Entire Path Of The SRC On Input Type="image"
capturing just the file name rather than the entire path of the SRC on my input type="image". Basically when I hover over an image, the Default Image should change to the image being hovered on. Here is my code, can't quite get it to work. Sorry I'm very new to JavaScript

<html>
<head>
<script language = "Javascript">
function ChangeDefault(src)
{
//document.frmMain.DefaultImage.src = src <--Doesn't work at all
alert(src) //<---Displays the entire file path, want just file name
[Code]...

Posted: 09-07-2010, 12:16 PM

View 3 Replies!   View Related
Jquery :: Create An Image Gallery With Image Swap Effect (click On "next" Button)
I'm trying to create an image gallery with image swap effect using Jquery. What I want to achieve is, when I click on a thumbnail (let's say No. 4), the main image would display image No. 4. Well, I've already successfully written a code for this matter. I have a "next"-button. If the main image is displaying image No. 4, clicking on the "next"-button should result in the main image displaying image No. 5. Or, if the main image is displaying image No. 7, clicking on "next"-button would show image No. 8 and so on.

Using the code I've written, clicking on the "next"-button will cause the main image showing the 2nd image. Clicking it again then it shows the 3rd image, but not the next No. from where I clicked the thumbnail.

[Code]...

Posted: Jan 23 11 at 2:15

View 2 Replies!   View Related
Image Swap - Get Replaced With A New Image
Lets say I have two images in a box

<body>
<div id="box">
<img src="image1.jpg" id="image1" width="100" height="100" />
<img src="image2.jpg" id="image2" width="100" height="100" />
</div>
</body>

When I click on Image1 I want Image2 to get replaced with a new image, called Image3. So I tried this code:

[Code]...

But instead of replacing the image on click, from some reason it replaces image2 with image3 from start/load.

Posted: 12-14-2010, 12:12 AM

View 2 Replies!   View Related
Swap Image Does Not Work With IE
I tried a Javascript on my homepage that works fine on Netscape, works
nearlyx normal on Opera but does not work at all on Internet Explorer. Is
there anybody out there who can help? I use a frameset of 3 frames. One of
these Frames has thumbnails with the javascript code for the image-swap -
the big picture should change whenever someone clicks on the corresponding
thumb. Code:

Posted: July 23rd, 2005

View 3 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved