views:

28

answers:

2

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 ?

A: 

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.

Darin Dimitrov
+1  A: 

You can embed the word into the url by doing this:

var lookup_url = "http://dictionary.reference.com/browse/" + your_word

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 ?

Justin L.