how to get src value from normal Text in javascript

<html>
<head>
</head>
<title>|| Video Uploader || </title>
<body>
<input type="text" id="video_url" name="video_url" value="<iframe   width='420' height='315'    src='https://www.youtube.com/embed/XGSy3_Czz8k'></iframe>"  />
<button id = "opener" onclick="insertURL()">Show URL </button>

<script type="text/javascript">
<!-- If User's Provide direct URL or Full iframe innerhtml-->
    function insertURL(){
        var ishare_url = document.getElementById("video_url").value;
       
        if(undefined!==ishare_url.split('src=')[1]){
        var src = ishare_url.split('src=')[1].split(/[ >]/)[0];
        if(src){
            var decode_ishare_url = decodeURI(src.trim());
            var replace_String = decode_ishare_url.replace(/%22/g, '');
            var replaceQuotes = replace_String.replace(/['"]+/g, '');
            document.getElementById("video_url").value = replaceQuotes;//Assign updated value
           
            }
        }else {
            if (ishare_url){
            var decode_ishare_url = decodeURI(ishare_url.trim());
            var replace_String = decode_ishare_url.replace(/%22/g, '');
            var replaceQuotes = replace_String.replace(/['"]+/g, '');

            document.getElementById("video_url").value = replaceQuotes;//Assign updated value
            }
            }
            alert("SRC ::    "+document.getElementById("video_url").value);
    }   
   
    function clearFieldValue() {
    // Clear urls Fields here
    document.getElementById("video_url").value = "";
}
window.onload = clearFieldValue;       
</script>
</body>
</html>

Comments

Popular posts from this blog

Converting JSONArray into CSV file in java

Java Design pattern

Map class field to map