cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Where does the JavaScript go?

Where does the JavaScript go?

Lisa S.66
New member | Level 1

I am very new at this. Where do I put the JavaScript at to make the chooser appear on my webpage?
This link says to use the JavaScript.
https://www.dropbox.com/developers/dropins/chooser/js#triggering

8 Replies 8

Ryan M.
Helpful | Level 7

Sounds like you might want to start here:

JavaScript Introduction: Where To
http://www.w3schools.com/js/js_whereto.asp

The demo instructions on the Dropbox website tell you what to embed on the page

<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="YOUR_APP_KEY"></script>

Greg-DB
Dropbox Staff

The JavaScript code on a web page should go in a <script> tag. As for when to run it, for the JavaScript that creates the button, you'll probably want to run that when the page loads. How exactly you do that depends on what libraries you're using, if any, (e.g,. jQuery, etc.), so I can't answer that specifically for you.

Of, if you are using a custom button instead, the JavaScript to trigger the Chooser to appear should be run from the event caused by the user (e.g., when they click a custom button or like on your page).

Lisa S.66
New member | Level 1

Okay, so I added this

<button type="button">Try it</button> 

after

<style>
    var button = Dropbox.createChooseButton(options);
    document.getElementById("container").appendChild(button);
</style>

I do not think that was was I was supposed to do.

Greg-DB
Dropbox Staff

Your button doesn't seem to be hooked up to anything, and you added your JavaScript code inside a <style> tag instead of a <script> tag.

I recommend reading through the Chooser documentation again, and getting some help with the general HTML/CSS/JavaScript development for your page if you're having trouble. That's outside the scope of Dropbox API support of course though, so I can't offer much help there.

I have a simple sample page that uses the Chooser here though:

https://dl.dropboxusercontent.com/u/27506755/chooser_js_simple.html

You can look at the source to see how it works.

Lisa S.66
New member | Level 1

I very much thank you for all your help. I am actually starting to get somewhere with all other this.
Okay, so I have this
https://www.dropbox.com/s/5ytuljdzhg4i07x/Screen%20Shot%202015-07-15%20at%203.37.51%20PM.png?dl=0
but I get this
https://www.dropbox.com/s/6a5ya9zogitjfz7/Screen%20Shot%202015-07-15%20at%203.39.25%20PM.png?dl=0

What am I doing wrong?

Greg-DB
Dropbox Staff

When using Drop-ins the domain(s) you want to use it on must be pre-registered on the App Console:

https://www.dropbox.com/developers/apps

Click on your app there and enter the domain for your site in "Drop-ins domains".

Lisa S.66
New member | Level 1

Thanks Greg! It works! Unfortunately though this is not what I thought It was. I need the users to be able to view and download from a specific app folder and only that specific app folder without having to sign in. Is there something like that?

Greg-DB
Dropbox Staff

No, there currently isn't a way to restrict the Chooser to a certain path like that, but I'll be sure to pass this along as a feature request.

(Unless you mean you want them to be able to view and download from your account only? In that case, you may just want to use a shared link to a folder in your account: https://www.dropbox.com/help/167 )

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Lisa S.66 New member | Level 1
What do Dropbox user levels mean?