5

FINAL UPDATE:

just in-case if anybody else is looking the error message solution which I was getting is due to the fact that: When you get a share link, the link points to a web page that displays the content. To get the raw content, use ?raw=1 See https://www.dropbox.com/help/201.

so I end-up adding ?raw=1 in the url and its working fine

Hope this will help others

EDIT 2:

in VFP page I have:

<script type='text/javascript' src='https://www.dropbox.com/....'>

and tried this both get the same error message

<script src='https://www.dropbox.com/.....'>

error:

Refused to execute script from 'https://www.dropbox.com/...' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

EDIT:

The other option I have tried is uploading the JS file to on the web site and try accessing it from the VFP and I see that I'm getting error:

VFP:

<script type='text/javascript' src='http://****/js/myjavscript.js'>

Error:

'http://****/js/myjavscript.js'. This request has been blocked; the content must be served over HTTPS.

So far, I have seen all the examples that related with uploading your resource then accessing but is that possible to have a reference on your local machine and access the resources? in my particular example I'm working with JS file that constantly needs to do changes till the development is done, I'm looking a way to make changes to JS file locally and still easily able to access in VFP

  • You are welcome :) – Nick Kahn Sep 2 '15 at 18:30
3

As a workaround, you can host non-sensitive JS files on a file host such as Dropbox, save the JS files in your synched folder, and link to them from your VF file with their public link.

enter image description here

enter image description here

When you save the JS file locally, your changes will automatically be synched to the online versions and will update your Visualforce page.

I've used this approach when working on JS applications before, and it works great. The links support HTTPS, so they should be fine for your use case.

See the Dropbox documentation for more information on linking to hosted files.

  • I did similar to the dropbox instead I have used my website and please see my updated question and let me know what your thoughts on the error. – Nick Kahn Sep 2 '15 at 13:50
  • Dropbox public links support HTTPS. You should be fine. – Rob Sep 2 '15 at 13:51
  • As an example, try including dl.dropboxusercontent.com/u/3332104/test/test.js . It should alert Success!. – Rob Sep 2 '15 at 13:55
  • did not get alert but i see alert('Success!'); – Nick Kahn Sep 2 '15 at 13:56
  • It sounds like you didn't link to the file properly. See e.g. w3schools.com/tags/att_script_src.asp and please update your post with your current code. – Rob Sep 2 '15 at 13:58
4

Visualforce pages are served from a different server than your Salesforce instance. Salesforce caches static resource to make them faster to load.

Unless Salesforce can establish a link to your local machine like it can with a CDN resource, there would be no way for you to do what you ask. You might find that using a development environment like Eclipse or Sublime Text may make it easier for you upload revisions to your Javascript libraries.

  • I do understand the establishing a link to resource but what is the other alternative.... instead of keep uploading the JS file revisions after revisions? I have update my question, please have a look – Nick Kahn Sep 2 '15 at 13:46
  • You're going to need to upload it to someplace where Salesforce can establish a secure connection or create a secure connection with your local machine. I doubt you want to go to the trouble of establishing your machine as having that kind of security certificate. Again, I recommend working with a development environment to use as an editor for making your JS changes that can also easily upload your changes as a static resource. – crmprogdev Sep 2 '15 at 13:54
  • If your comfortable with the command line, you may want to look into using ant deployments. They tend to be pretty fast and allow you to use any editors you want. – battery.cord Sep 2 '15 at 14:22
  • @AbuHamzah. As you've edited your question to include drop box, I don't understand how synching your changes with dropbox is any different than uploading them to update a static resource using a dev environment. I recognize it's also s a matter of what you're most comfortable working with. – crmprogdev Sep 2 '15 at 14:27
  • @crmprogdev: the problem with uploading every time to static resource is a big pain then modifying js file from the folder which is directly sync without me uploading every time i make revision so by far the syncing option is the best in order to avoid every time upload. thanks – Nick Kahn Sep 2 '15 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.