Loading url from textbox to iframe

How do you load url from textbox in iframe to HTML file via javascript?

0


a source to share


3 answers


var oIFrame = document.getElementById("id_of_iframe");
oIFrame.src = document.getElementById("id_of_textbox").value;

      



+7


a source


Or with document.frames if it's the only iframe you're using:



var myIframe = window.document.frames[0]; // lets grab the iframe object
if (myIframe != null){
  myIframe.src = document.getElementById("id_of_textbox").value; // set the value as source.
}

      

0


a source


Just add, I think, via jQuery

$('iframe#guid').src( $('#textbox_id').val() );

      

with error checking:

var iframe = $('#guid');
if(iframe.length > 0){
    iframe.attr('src', $('#textbox_id').val());
}

      

0


a source







All Articles