Is there a shorthand way to document.createElement multiple elements?

Is there a shorthand method in JS to document.createElement when you’re creating a bunch of elements.

To maximize usage of HTML5, and still make sites work in older browsers, I tend to have something like this snippet of JS in every site I do:

// Allows HTML5 tags to work in older browsers

Is there a way to add them via one statement — comma separated or something similar?


var elements = ['header', 'nav', 'section', 'article', 'aside', 'footer'];
for (var i = 0; i < elements.length; i++) {

Javascript – Best way to encrypt data with password

I’m creating a server which can store cookies on the web that will contain application settings. The server will accept any data, but I want to encrypt all the settings before storing them in a cookie and decrypt them when reading them out. So I can store very sensitive data like Account Usernames & Passwords in the cookies and the server cannot do anything with it.

My question is now: What is the best way to encrypt such data with a password in JavaScript on the client side? What is the most secure?

I need some code that I can embed into my site and use it from there.


I’d recommend using AES encryption in your JavaScript code. See Javascript AES encryption for libraries and links. The trouble you’ll have is picking a key that is only available on the client side. Perhaps you can prompt the user? Or hash together some client system information that’s not sent to the server.


How do you access Android credential storage?

In Settings > Location & Security there is a section that allows the user to import certificates. There is also an option, “Use secure credentials” that “Allow[s] applications to access secure certificates and other credentials”. I can find no mention of how to get to this in the documentation, and very few mentions of it online aside from people using it to connect to certificate-secured wifi networks. One of the only pertinent things I found was a post claiming that accessing these certificates was actually impossible for regular apps. Is this true? Does anyone know how to access these certificates if it isn’t or documentation somewhere that states it is not possible?


Take a look at this Android Issue for some discussion on the topic:

The Settings screen for installing root certificates can only be used for VPN and WiFi, unfortunately.


R cannot be resolved – Android, no import android.R; statement

I am working on a new app and everything worked fine as long as I used a Relative View. However, I want a tabbed layout so I switched what I had (not much so far since I just got it reading from a DB and settings working) over to a tabbed view. Since that time, any class that has any R. statement in it has an “R cannot be resolved” error. I am following the tutorial from the Android “Hello Views” tutorial so I am assuming that isn’t the issue (but it could still be).


I have a few suggestions:

  1. Make sure you don’t have any other errors other than the R-related errors. Right-click your project folder in Eclipse, Android Tools -> Fix Project Properties.

  2. Check to make sure you have the correct R imported. Sometimes the default Android.R can be imported.

  3. Check for errors in your layout XML files.


Maven – Always download sources and javadocs

Is there a way I can configure maven to always download sources and javadocs? Specifying -DdownloadSources=true -DdownloadJavadocs=true everytime (which usually goes along with running mvn compile twice because I forgot the first time) becomes rather tedious.


Open your settings.xml file ~/.m2/settings.xml (create it if it doesn’t exist). Add a section with the properties added. Then make sure the activeProfiles includes the new profile.


   <!-- ... other settings here ... -->


Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..