Replacing imgur with filmot,
Input box - https://i.sstatic.net/Uguvn.jpg
Submit button
Once the submit is clicked in a new tab http://i.filmot.com/abcde.jpg has to open.
<html>
<head>
<title>input</title>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
function myFunction() {
var res = str1.replace("imgur", "filmot");
var win = window.open(res, '_blank');
win.focus();
});
</script>
</head>
<body>
<form>
<input type=”text” id=”str1” />
<button onclick="myFunction()">Click</button>
</form>
</body>
</html>
The return code is not working. Please suggest.
Thanks :)
EDIT:
Here is solution code :)
<html>
<head>
<title>input</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
function myFunction() {
var str1 = document.getElementById('str1').value;
var res = str1.replace("imgur", "filmot");
document.getElementById('str1').value = res;
var win = window.open(res, '_blank');
win.focus();
}
</script>
</head>
<body>
<input type="text" id="str1" />
<button onclick="myFunction()">Click</button>
</body>
</html>