简体   繁体   中英

HTML set User-pasted Image URL as img src

Okay. I have an image on my website that I would like users to be able to change by pasting a image URL into a text input field and pressing enter. I have the input and image set up, I just don't know how I could take the text that the user pasts into the box, and set it as the img src.

Here is my input

<Input type="text" id="usrimg">

And here is my Image code I want to change to the URL pasted in the box above

imageObj.src = "http://WHATEVERURLUSERPASTES.co";

Any ideas?

javascript?

var imageObj.src = document.getElementById('YOURID').value;

Server side code? PHP, C#, VB.NET, Vbscript, Jscript, anything usable for CGI?
Pseudo code:

var imgobj = (find img)
imgobj.src = query(usrimg)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM