Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

add java script to html

Name: Anonymous 2009-05-01 7:20

how can i add java script to html? this way it doesn't work:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>aa</title>
</head>
<body>
<img style="width: 117px; height: 37px;" alt=""
 src="buttons/shop1.png" id="shop">
<script type="text/javascript">
var x = 0
var y = 0
var shop = document.getElementById("shop-img");
onMousedown = mouseDown();
onMouseup = mouseUp();
onMouseout = mouseOut();
onMouseover = mouseOver();
onMousedown = mouseDown();
function mouseDown()
{
shop.src = 'buttons/shop3.png';
}
function mouseUp()
{
shop.src = 'buttons/shop4.png';
var x = 1; var y = 1;
}
function mouseOut()
{
if (x == 2) {
shop.src='buttons/shop4.png';
} else {
shop.scr='buttons/shop1.png'; }
}
function mouseOver()
{
if (y == 2){
shop.src='buttons/shop3.png';
} else {
shop.src='buttons/shop2.png';
} }
</script>
</body>
</html>

Name: Anonymous 2009-05-01 9:19

OMG your code SUCKS!

Name: Anonymous 2009-05-01 10:58

Read Secrets of the JavaScript Ninjas!

Name: Anonymous 2009-05-01 11:31

your the same fag as the post with the other shit javascript in it fuck off.

Name: Anonymous 2009-05-01 16:57

Besides being perversely awful code, my guess of what problem you want identified is this section:
var shop = document.getElementById("shop-img");
onMousedown = mouseDown();
onMouseup = mouseUp();
onMouseout = mouseOut();
onMouseover = mouseOver();
onMousedown = mouseDown();

Code in the <head> of your document is executed before the DOM is loaded, so "shop-img" doesn't actually exist in the context of the script when it is running. You can fix this by attaching your code to a window.onload event, or using the better jQuery alternative $(document).ready(function() { ... As well as that, the next four lines of code don't actually do anything- and may throw errors as well. "onMousedown" in your code is being treated as an lvalue, so what is happening is the local variable "onMouseDown" is being assigned a function pointer, and itself becomes a function. If you were looking to tell it what to do on the javascript "onmousedown" event, then you will need to a)watch your case sensitivity, and b)attach it as an attribute to the element. i.e., shop.setAttribute("onmousedown", "alert('PENIXEN!')");

Name: Anonymous 2009-05-02 3:12

what the fuck?
first, lets transform your code into something that actually makes sense.
this uses mootools.



window.addEvent('domReady', function(){
    var x = 0;
    var y = 0;
   
    $('shop').addEvents({
        'mousedown':function(e){
            this.set('src', 'buttons/shop3.png');
        },
        'mouseup':function(e){
            this.set('src', 'buttons/shop4.png');
            x=1;
            y=1;
        },
        'mouseout':function(e){
            var src = (x==2) ? 'buttons/shop4.png' : 'buttons/shop1.png';
            this.set('src', src);
        },
        'mouseover':function(e){
            var src = (x==2) ? 'buttons/shop3.png' : 'buttons/shop2.png';
            this.set('src', src);
        }
    });   
});


now look. what's going on with that x and y? it's never ever going to be 2.

Name: Anonymous 2009-05-02 3:39

>>5,6 SHUT UP!!!

Name: Anonymous 2009-05-02 3:40

I forgot to sage.
It doesn't make sense now, and I do it only to show how much I am disgusted with >>1

Name: Anonymous 2009-05-02 5:28

>>7
hahaha, disregard that I suck cocks

Name: hahaha, disregard that I suck 2009-05-02 5:44

>>9
Anonymous

Name: Anonymous 2011-01-31 21:12

<-- check em dubz

Name: tray 2012-03-14 17:01

you better be

Name: Anonymous 2013-08-31 19:52


Protein shakes are a good source of protein, which is important to get after a workout. You should always make an effort to at least try to eat some protein after a workout. But it could be in a shake format, a snack format, a meal format — anything you want to eat. Some people swear by shakes, but it doesn't really matter as long as you get it somehow.

Name: Anonymous 2013-08-31 21:22


I had a Russian BF once and he was hung like a dang elephant! I love anal, but with him it was a real challenge getting it done without a good amount of lube

Don't change these.
Name: Email:
Entire Thread Thread List