PHP gevorderde |
|
Ok, nu werkt de tweede split niet.
FireBug:
Citaat: urla[1] has no properties
urlcolour("red")index.php (line 9)
onmousedown(mousedown clientX=0, clientY=0)index.php (line 1)
[Break on this error] var urlb = urla[1].split('&', 1);
Script:
function urlcolour(colour) {
var url = String(document.location);
alert(url);
var urla = url.split('&colour=');
alert(String(urla[0]));
var urlb = urla[1].split('&', 1);
alert(urlb[0]);
var urlc = String(urlb[1]);
alert(urlc);
if (urlc != "") {
urlc = '&' + urlb;
}
if (urla[1] == "") {
alert(url + '&colour=' + colour);
<!-- document.location = url + 'colour=' + colour; -->
} else {
alert(urla[0] + '&colour=' + colour + urlc);
<!--document.location = urla[0] + 'colour=' + colour + urlc; -->
}
}
function urlcolour(colour) { var url = String(document.location); alert(url); var urla = url .split('&colour='); alert(String(urla[0])); var urlb = urla [1].split('&', 1); alert(urlb[0]); var urlc = String(urlb[1]); alert(urlc); if (urlc != "") { urlc = '&' + urlb; } if (urla[1] == "") { alert(url + '&colour=' + colour); <!-- document.location = url + 'colour=' + colour; --> } else { alert(urla[0] + '&colour=' + colour + urlc); <!--document.location = urla[0] + 'colour=' + colour + urlc; --> } }
|