javascript run from web browser [closed]
i was wondering if you people could give me an example code for people to type in their address bar to automatically download something from a web address just by typing in that javascript line. Thanks
Isn't that how URLs work already? Download something when you just type in the web address?
No JavaScript Needed!™
I'm gonna take a wild guess and assume your problem is that the file is opening in the browser, but instead you want it to be downloaded. That's not really a JS problem. You need to set/change the mime-type of whatever file you want people to download. application/__ usually works. _ being the type of file. look here: http://www.w3schools.com/media/media_mimeref.asp
There's also this other header which is sort of an extension of MIME you can add:
Content-disposition: attachment; filename=someFileName
More on that here: http://support.microsoft.com/kb/260519
If it's something that's generated through php, you can throw this at the top:
More info would be useful so I supply you with a better example.
This should do it:
javascript:window.location.href=http://images.google.com/search?tbm=isch&hl=en&source=hp&biw=1482&bih=801&q=you+people%3F%21&gbv=2&aq=f&aqi=g3g-m7&aql=f&oq=
Sounds like you need BookMarklet.
精彩评论