How to get the file using it's URL in Javascript?

How do I get input using Javascript in a bookmarklet?

  • I am trying to write some code to append a URL with some text. So that the action would be - click a button, get input from user, go to output. I have tried writing this (I have removed the real URL): "javascript:spam_check=location.href(C… TEXT INPUT HERE)" - this may not display correctly here, so will also explain below. So you can see, I want to insert a username at the end of this URL using javascript - xxxxxx.co.uk/something/?user=, when a user click the bookmarklet, they can enter a username, it will then go to the desired page. I'm a bit of a noob, this should be easy, I've tried some different solutions but can't get it right. Cheers!!

  • Answer:

    If it this what you are trying to do, bookmarklet is not the way to go. Button on website. Click button show input field. Collect detail. Submit form. Put details in url and redirect. Bookmarklet are link smart widgets stored in bookmarks, ran by clicking it so it "does something" before site loads or on the current site using javascript code. Regardless, here is an answer to how to activate a bookmarklet. 1) Create a working javascript code, as one block, no function included. 2) If the last action you need is open a url, don't place the url at the begining but at the end of the code use window.location='http://www.gothere.com?… 3) Use a tool to compress javascript (online example in source) 4) Use a tool to encode the comressed script 5) append javascript: to the result string, and that is the url value you use. e.g for alert('woohoo'); you get "alert(%27woohoo%27)%3b%0d%0a" so <a href="javascript:alert(%27woohoo%27)%3b%…

DiggNati... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.