Reputation: 29
I have a website http://speedie.mobi/emulator4/ and I would like to add a text box where people could add their own url to change what appears in the mobile phone.
It is just using a simple iframe browser.
So by adding their url in the text box it would replace the current url with their url.
Quentin
Upvotes: 1
Views: 2923
Reputation: 286
Using jQuery,
var url = $('#urltext').value();
$('#targetframe').attr('src',url);>
Upvotes: 2
Reputation: 15877
<script>
function goTo() {
var input = get("box").value,
frame = get("frame");
if(input.match(/\bhttp(.)*/)) {
frame.src = input;
} else {
input = "http://" + input;
frame.src = input;
}
}
function get(id) {
return document.getElementById(id);
}
</script>
<input type="text" id="box" value="http://www.example.com" />
<button onClick="goTo();">go</button>
<iframe src="http://www.example.com" frameborder="0" id="frame" width="100%" height="90%"></iframe>
Upvotes: 3