Tell us what’s happening:
Hi guys I’m trying to write code that removes some special characters from any string URL
and then displays the cleaned string via html.
the javascript works but I can’t seem to get the result to show in the browser. pls help!
Your code so far
<!DOCTYPE html>
<html>
<head>
<title>Clean URLs</title>
</head>
<body>
<div id="display-area" >
<textarea placeholder="insert URL here :)" id="myTextarea"></textarea>
<button class = 'btn btn-default' id="demo"> Cleanup URL</button>
</div>
<div id ="result1"><p></p></div>
<div id ="result2"><p></p></div>
</body>
</html>
<script>
var splitstring = [''];
var finaloutput = ''; var i = 0;
function cleanupurl(urlstring) {
//==========================================//
urlstring = urlstring.replace(/%21/gi, '!');
urlstring = urlstring.replace(/%23/gi, '#');
urlstring = urlstring.replace(/%24/gi, '$');
urlstring = urlstring.replace(/%26/gi, '&');
//==========================================//
splitstring = urlstring.split('http://');
document.getElementById("result1").innerHTML = cleanurloutput1();
//return
}
function cleanurloutput1(){
return splitstring[1];
}
function cleanurloutput2(){
return splitstring[2];
}
//document.getElementById("result1").innerHTML = cleanurloutput1();
var x = document.getElementById("myTextarea").value;
cleanupurl(x);
</script>
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5
.
Link to the challenge: