HTML 将用户粘贴的图像 URL 设置为 img src
好的。我的网站上有一个图像,我希望用户能够通过将图像 URL 粘贴到文本输入字段并按 Enter 来更改该图像。我已经设置了输入和图像,我只是不知道如何将用户粘贴到框中的文本并将其设置为 img src。
这是我的输入
<Input type="text" id="usrimg">
这是我的图像代码 我想更改为粘贴在上面框中的 URL
imageObj.src = "http://WHATEVERURLUSERPASTES.co";
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JavaScript?
var imageObj.src = document.getElementById('YOURID').value;
javascript?
var imageObj.src = document.getElementById('YOURID').value;
服务器端代码? PHP、C#、VB.NET、Vbscript、Jscript,任何可用于 CGI 的语言?
伪代码:
Server side code? PHP, C#, VB.NET, Vbscript, Jscript, anything usable for CGI?
Pseudo code: