Javascript examples for String Operation:String URL
Check URL protocol
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww . j a va2 s.c o m url="ftp://example.com"; protocols = ['http', 'https', 'ftp', 'sftp', 'ssh', 'smtp']; protocols.forEach(function(item) { if(url.indexOf(item) != -1) { newUrl = "http://"+url.substr(url.indexOf("//")+2); } }); console.log(newUrl); } </script> </head> <body> </body> </html>