Changing Background Using OnClick?

Aug 31, 2011

Here is my script -- Applied in <head>

<script language="JavaScript">
var bgImage = new Array(); // don't change this
bgImage[0] = "images/aboutus_1.jpg";

[code]....

this goes on, however, it does not change the background when clicking on "Welcome" or "About us" Links. Where I want "About us" to load image#0 in the index and "Welcome" to load image #1.

View 1 Replies


ADVERTISEMENT

Changing Tr Or Td Background?

Jan 2, 2009

I have simple code that I need to make function. The idea is to change background on <tr> or all <td> that belong to one tr.

Code HTML4Strict:
<html>
<head>[code]....

View 3 Replies View Related

Changing Background Colour

Jul 23, 2005

I spotted some nice code to change the background colour of a web page to
one of four different colours at random but I can't find it now!

The method was to select a number at random from 1 to 4 by using the rnd()
function and then dividing by modulus 4. The result was then used to select
a cell in a 4 cell array which was holding a different colour in each cell
of the array. I would like to have this code but lack the knowledge to
re-create it.

View 4 Replies View Related

Changing Div Background Isn't Working

Dec 29, 2009

I'm trying to change the background of a <div>. I'm using a thumbnail of an image so when the user clicks the thumbnail, depending on the size of the thumbnail the background of another <div> (where the larger image is displayed) will change.

I have it working..sort of. When I click the thumbnail the background will change to the specified image but after a couple of seconds it changes back to the original background on its own. I have no idea why this is happening.

This is where the code is to call the javascript method...

Code:

This is the css for the <div>..

Code:

And this is my javascript code...

Code:

View 3 Replies View Related

Changing Background Image Of Td?

Jun 10, 2009

EDIT: for some reason it is working now, but i have a new question: how do i change the background to no background?

View 5 Replies View Related

Changing Div Background Image?

Sep 29, 2011

i want to set dynamically a div's background image when the page loads, so I have my code like so:

javascript code:
window.onload = init;
function init(){
$(document).ready(function(){
$('#button1').css('background', 'url(../imagenes/buttonNormal.jpg)');
$('#pg1').css('color', 'black');

[Code]...

View 2 Replies View Related

Changing Background Image?

Sep 26, 2009

I've been trying to figure out how to change the background image with javascript, and I've tryed a whole bunch of code this being one of them

var imageURL = "/images/content/rotator/IMG_2019.jpg";
document.body.style.backgroundImage = "url(" + imageURL + ")";

or

document.body.style.backgroundImage = "/images/content/rotator/IMG_2019.jpg";

or

document.body.background = "/images/content/rotator/IMG_2019.jpg";

With using the last one I get 'document.body' is null or not an object, but I do have a <body> tag in my page.And if I do

if (document.body){
alert("hello");
}

I dont get anything.How can I get this code to work?

View 4 Replies View Related

Tile Background Changing?

Nov 22, 2010

i creating a 'map' for my game. I've got a 13x13 tile layout and using PHP I've loaded all the tiles.What I'm looking to do is grab all the tiles whose class names are 'water' and create a loop that'll change their background every second between four possible images.

View 1 Replies View Related

Changing Div Background-Images?

Sep 29, 2008

I've got a Javascript which changes the background image of the body by rotating other images. What I want is the script to change the background to a specific div and not of the whole body section. Since I'm not an expert in Javascript I have Googled a lot but couldn't work it out till now. In other words that I want is to alter/change in the script the line "...document.body.background=processed [abc].src.." in a way and add ... so that this script works for a specific div and not only for the whole webpage...

<script language="Javascript">
var bgimage=new Array()
bgimage[0]="image1.png"[code]....

View 7 Replies View Related

Changing Background Pic On Mouse Over

Nov 25, 2003

How do I change the background picture of a table cell when the mouse is brought over it?

View 1 Replies View Related

Dynamically Changing Background Color

Jul 20, 2005

I'm having a problem dynamically changing the color of a table background.

I'm not sure exactly how to word this, but I'll give an example.

I have a function called greentored(propname)

i want to be able to change the following to a different color:
document.all.propname.style.visibility

but substitute the propname with the variable that I'm sending over.

Here is what I had written before but it did not work, it should be easy to
understand what i'm trying to do:

function greentored(propname) {

changecolor = "document.all." + propname + ".style.background";

changecolor = "green";

}

I understand why this doesn't work because all i'm doing is reasigning
"changecolor" to equal green, rather then setting the property of the first
instance of "changecolor" to green.

View 3 Replies View Related

Changing Background Colors WITH CSS Already Defined

Jul 4, 2010

I seem to be having a slight problem.

Code:

<script type="text/javascript">
<!--
document.bgColor='#33CCFF';
var x = 300;
while (x < 1500)

[Code]...

Basically, this makes the background flicker for a brief second. Great. However, if I set a background color using CSS (so the page isn't white if javascript is turned off) the flicker won't work.

View 1 Replies View Related

Changing Background Color Of Text Box

Feb 3, 2009

So I'm trying to change the background color of a textbox depending on how many characters are enter (putting it green/red depending on count), and I'm having a hell of a time. There are 50 different textbox IDs on the page (give or take, dynamically generated), each unique/sequentially numbered (id1, id2 ... id50).Now I'm not that good with Javascript, but this is what I can up with so far.I was trying to use 'this.id' so I wouldn't have to name each of the IDs.

View 2 Replies View Related

Changing A Background Image Using An Input Box?

Apr 23, 2009

I am using PHP and Javascript to create a user generated page editor. I have everything working except one thing. The user can select the background color of the page using preselected colors. They can also enter in a hexadecimal code to change the color of the background if the color they want isn't one of the preselected ones. These two things work good, but when it comes to them entering in a web address to make an image the background instead of a color, I can't get the background image to change. I have tested it out and when I enter in a predetermined url in the javas source code to test if the pic will display it does, but it doesn't go away after being displayed. So my question is using the code below, how can I get the change the background image using an input box and how can I make it go away when a color is selected instead of an image. Explained below:

[Code]...

View 2 Replies View Related

Get An On Click Changing Background To Stay?

Nov 20, 2010

I used this on-click changeable background code for my website code...

And now I have the same question as the original poster: is there any way to get it so that the chosen background stays put even if the page is refreshed or navigated away from? Or is it not possible because all my pages are separate files? code...

View 12 Replies View Related

Changing Background To The Zombies Image?

Apr 26, 2011

After you click on the last button 3 times it should change the background to the zombies image however it isn't working. I haven't found tutorials for doing it exactly as I am attempting it but I don't see why this isn't working.It runs through the code just fine and the button works as intended except for the fact that the background image isn't changing.

<html>
<title>Welcome :D</title>
<head>[code]....

View 11 Replies View Related

Changing Background Image On Hover?

Jun 30, 2011

I want javascript to change the background image on hover.

This is my javascript:
function navOver(obj){
var imgUrl = 'url(images/' + obj.id + '.hover.png) center no-repeat';
obj.style.background='imgUrl';
}
function navOut(obj){

[Code]...

View 5 Replies View Related

Changing Background Color From External Js

Aug 10, 2011

I want to create a basic script where someone clicks the button and the document color is changing. while I can do it with inline even handlers and also using the script block in html document, i am not able to achieve the result using the external js.js. My goal is not to use any even handlers at all inside the html document. why the script I wrote is not working.

View 7 Replies View Related

Changing Background-color Of Divs

Jan 3, 2006

I'm having problems with changing the background color of a div when it is hovered over. So here is my code:

function changeColor(the_div_name)
{
var the_div, div_string;
if (document.all)
{
div_string = "window.document.all." + the_div_name + ".style";
the_div = eval(div_string);
} else if (document.layers) {
div_string = "window.document." + the_div_name;
the_div = eval(div_string);
} else {
alert("sorry, this only works in 4.0 browsers");
return;
}
the_div.background-color = "white";
}

here is my code for the html:

<div name="div7" style="background-color:black; color:blue; position:absolute; top:95; left:664">
<a href="#"
</div>

View 10 Replies View Related

Changing Every 2 Rows Tr Background Color

Jun 27, 2011

how can i change every 2 rows the background color?

View 9 Replies View Related

Changing Background Color Of Iframe

Mar 27, 2007

I do not much understand what is going on. The iframe is transparent in all browsers but IE. I need to change the background color in IE, of my iframe and cannot figure it out. My code is below. It is pulling from an external file exfile.js.

View 8 Replies View Related

Changing Background Image/colour?

Jun 14, 2010

I'm having a problem with changing the background image on an element when I use the .hover() and .toggleClass() methods. Here's some code:

First the CSS:
Code:
.down-arrow {
cursor: pointer;
background: #efefef url(images/arrow-down.png) no-repeat 13px 13px;

[Code]....

It seems to work ok(ish) if I use the .css() method and change it directly in the code, but I want to try and keep my styling only in my CSS file and use classes to make the change.

View 2 Replies View Related

Changing EDIT BOX Background Color

Dec 18, 2005

I'm writing a script and I need to change the BACKGROUND and FOREGROUND color of a EDIT BOX Example:

<INPUT type="text" style="position:absolute;left:270px;top:210px;width:72px;background-color:#FF1111;z-index:26" size="9" name="BCBox" value="">

And the way I'm trying to do it is by reading the value of a COMBOBOX, I don't have a problem with that, just changing the color of the edit box.

View 2 Replies View Related

IFRAME - Changing Background Image

Jul 1, 2010

I have found a method which works in FireFox (2 - 3.6) & Mozilla but obviously it is not generic and IE is proving difficult to provide an attribute I can change. This (in essence) is what I am doing. I do have CSS styles and set the background (fixed, repeated) there in a style called body. The one below is an exapmple - I change the URL of the IFRAME contents several times before dumping the filtered table in the innerHTML. This leaves the background as the last one set.

Code:
body{
background-attachment: fixed;
background-image: url(images/gcount.jpg);

[Code]...

View 1 Replies View Related

Changing Background Image With A Button?

Sep 13, 2010

I am trying to make a button that would change the background image whenever somebody clicks it.

I have tried something along the lines of this:

Quote:
<input type="button"
value="Pattern1"
onClick="background-image: url(background.png);background-repeat: no-repeat;">

[Code]...

View 5 Replies View Related

Clicking A Row And Changing The Background Color?

Jun 9, 2011

I am trying to highlight a row when it is clicked I can do this with: onclick="this.style.backgroundColor='silver';" However I have the following onclick function:

Code:
window.onload= function(){
document.getElementById('itblResults').onclick= function(e){
e= e || window.event;
var who= e.target || e.srcElement;

[Code]...

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved