Javascript simple problem

gaptrast

Member
Messages
123
Reaction score
0
Points
16
Hello,

I have a small problem; it will not work!!!

heres my code:::
Code:
<head>
<script type="text/javascript">
function download() {
var base_url="http://www.example.com/valum.php?";
var qs="koke";
var dl = document.getElementById( "dl" ) ;
var total = "window.location='" + base_url + "'";
dl.onclick = total;
}
</script>

</head>
<body>



<img id="dl" onclick="download();"  src="kokkelimonke.jpg" />

</body>


When I click at the image nothing is happening... I should have been be redirected to http://www.example.com/valum.php?koke , but nothing is happening!!!!
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
Try this:
Code:
<head>
<script type="text/javascript">
function download(){
var base_url = "http://www.example.com/valum.php?";
var qs = "koke";
window.location = base_url + qs;
}
</script>

</head>
<body>



<img id="dl" onclick="download();"  src="kokkelimonke.jpg" />

</body>
I'm not entirely sure how you are intending to extend this, so I haven't simplified it as fully as it'll go.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Exactly what do you want it to do?

Are you actually trying to change the onclick handler in download()?
 
Top