Jump to content

NEWBY NEWB NEWB problem


lAZLf

Recommended Posts

Why wont this code work:

	document.getElementById("bg").style.background= "transparent url('svid.png') fixed no-repeat 10px 30px";

 

When this code does:

	document.body.style.background = "#CCC url('svid2.png') fixed no-repeat 10px 30px";

 

 

 

 

 

Incase you're curious, here's the code i'm working with:

var winW = 630, winH = 460;

if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
}
if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth;
  winH = document.body.offsetHeight;
}
}

if(winW > 1270) {
document.body.style.background = "#CCC url('svid2.png') fixed no-repeat 10px 30px";
document.getElementById("bg").style.background= "transparent url('svid.png') fixed no-repeat 10px 30px";
}

Link to comment
https://forums.phpfreaks.com/topic/191549-newby-newb-newb-problem/
Share on other sites

Firstly is there an error in the console?

 

Secondly is it getting an object? try changing it to something simple like:

 


document.getElementById("bg").innerHTML='test';

 

if that is working then try just giving it a class instead of that inline stuff

 


<script js>

document.getElementById("bg").setAttribute("class", "myClass");

</script>

<style>

.myClass{

background: transparent url('svid.png') fixed no-repeat 10px 30px;

}

</style>

In firebug I get this error:

uncaught exception: [Exception... "Not enough arguments"  nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)"  location: "JS frame :: http://svidler.net/ :: <TOP_LEVEL> :: line 17"  data: no]
http://svidler.net/
Line 76

 

and this error:

document.getElementById("bg") is null
http://svidler.net/
Line 76

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.