如何使用 Javascript 从网站读取文本?
我正在为我的手机编写 HTML 代码。它本质上是一个词典应用程序,我可以在其中输入一个单词,然后从 Dictionary.com 等网站查找其含义;
我正在使用 Javascript 来获取字符串,但我可以将单词嵌入到 URL 中吗?“http://dictionary. Reference.com/browse/”
有什么方法可以做到这一点吗?
I am writing an HTML code for my cell phone. Its essentially a Dictionary App where I input a word and I look up the meaning from say, Dictionary.com ;
I am using Javascript to get the string but can I embed the word into the URL, "http://dictionary.reference.com/browse/"
Is there any way of doing this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过执行以下操作将单词嵌入到网址中:
从那里,这取决于您想要如何加载网站。不幸的是,没有办法用 JavaScript 远程查询网站。您将不得不使用您可以使用的其他工具。在那之前,也许您可以只执行
window.location = Lookup_url
?You can embed the word into the url by doing this:
From there, it depends on how you want to load the website. Unfortunately, there is no way to remotely query the website from afar in JavaScript. You're going to have to use some other tool you have at your disposal. Until then, maybe you can just do
window.location = lookup_url
?由于同源政策限制,这对于纯JavaScript来说是不可能的。如果第三方网站提供支持
JSONP
那么这可以工作,但在一般情况下不行。
Due to same origin policy restrictions this is not possible with pure javascript. If the third party web site provides an API that supports
JSONP
then this could work but not in the general case.