cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Where does the JavaScript go?

New member | Level 1
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
Highlighted

Re: Where does the JavaScript go?

Helpful | Level 5

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>
Highlighted

Re: Where does the JavaScript go?

Dropboxer
Dropboxer

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).

Highlighted

Re: Where does the JavaScript go?

New member | Level 1
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.

Highlighted

Re: Where does the JavaScript go?

Dropboxer
Dropboxer

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.

Highlighted

Re: Where does the JavaScript go?

New member | Level 1
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?

Highlighted

Re: Where does the JavaScript go?

Dropboxer
Dropboxer

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".

Highlighted

Re: Where does the JavaScript go?

New member | Level 1
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?

Highlighted

Re: Where does the JavaScript go?

Dropboxer
Dropboxer

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 )

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?