Title: Shortcode &#8211; Javascript
Last modified: August 22, 2016

---

# Shortcode – Javascript

 *  Resolved [ValerioCappelli](https://wordpress.org/support/users/valeriocappelli/)
 * (@valeriocappelli)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/shortcode-javascript/)
 * Hi all,
    i have this code in my post:
 *     ```
       <body onload="detectmob()">
       <p><strong>scarica la musica</strong><p>
       <button onclick="detectmob()">Try it</button>
       <div id="textDiv">[sell_downloads columns=4]
       </div>
       </body>
       ```
   
 * detectmob function is:
 *     ```
       function detectmob() {
        if( navigator.userAgent.match(/Android/i)
        || navigator.userAgent.match(/webOS/i)
        || navigator.userAgent.match(/iPhone/i)
        || navigator.userAgent.match(/iPad/i)
        || navigator.userAgent.match(/iPod/i)
        || navigator.userAgent.match(/BlackBerry/i)
        || navigator.userAgent.match(/Windows Phone/i)
        ){
   
       var div = document.getElementById("textDiv");
           div.textContent = "[sell_downloads columns=1]";
           return true;
         }
        else {
   
       var div = document.getElementById("textDiv");
           div.textContent = "[sell_downloads columns=4]";
   
           return false;
         }
       }
       ```
   
 * But this code print the TEXT “[sell_downloads columns=4]” and not change text
   in shortcode.
 * How i can add different shortcode in javascript code?
 * I need this because my responsive theme is so bad!
 * Thank you so much for help..
 * Valerio
 * [https://wordpress.org/plugins/sell-downloads/](https://wordpress.org/plugins/sell-downloads/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/shortcode-javascript/#post-5780824)
 * Hi Valerio,
 * The shortcodes are replaced in the server side and not in the browser, so you
   cannot check the shortcode with javascript. Please, test the following customization:
 * 1. Open the “/wp-content/plugins/sell-downloads/sell-downloads.php” file with
   the text editor your choice.
 * 2. Go to the line of code:
 * `function load_store_product_list($atts){`
 * and modify it like follow:
 *     ```
       function load_store_product_list($atts){
       $useragent=$_SERVER['HTTP_USER_AGENT'];
       if ( preg_match( '/android|webos|iphone|ipad|ipod|blackberry|windows phone/i', $useragent ) ) $atts[ 'columns' ] = 1;
       ```
   
 * and that’s all
    Best regards.
 *  Thread Starter [ValerioCappelli](https://wordpress.org/support/users/valeriocappelli/)
 * (@valeriocappelli)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/shortcode-javascript/#post-5780826)
 * Thank you so much!
 *  Thread Starter [ValerioCappelli](https://wordpress.org/support/users/valeriocappelli/)
 * (@valeriocappelli)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/shortcode-javascript/#post-5780864)
 * Emh… i’m sorry but in latest new versione of sell download i not found this row:
 * `function load_store_product_list($atts){`
 * Are u sure i can find too in free versione of sell download?
 * Thank you again!
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/shortcode-javascript/#post-5780867)
 * Hi,
 * I’m sorry, my fault, the correct function to edit is:
 * function load_store($atts){
 * and the code would be:
 *     ```
       function load_store($atts){
       $useragent=$_SERVER['HTTP_USER_AGENT'];
       if ( preg_match( '/android|webos|iphone|ipad|ipod|blackberry|windows phone/i', $useragent ) ) $atts[ 'columns' ] = 1;
       ```
   
 * Best regards.
 *  Thread Starter [ValerioCappelli](https://wordpress.org/support/users/valeriocappelli/)
 * (@valeriocappelli)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/shortcode-javascript/#post-5780871)
 * Find and work!
    The name exactly:
 * `function load_store($atts, $content, $tag){`
 * Can you help me with:
 * [https://wordpress.org/support/topic/streaming-audio-on-list-of-element?replies=2](https://wordpress.org/support/topic/streaming-audio-on-list-of-element?replies=2)
 * Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Shortcode – Javascript’ is closed to new replies.

 * ![](https://ps.w.org/sell-downloads/assets/icon-256x256.jpg?rev=1058371)
 * [Sell Downloads](https://wordpress.org/plugins/sell-downloads/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sell-downloads/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sell-downloads/)
 * [Active Topics](https://wordpress.org/support/plugin/sell-downloads/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sell-downloads/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sell-downloads/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [print](https://wordpress.org/support/topic-tag/print/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 5 replies
 * 2 participants
 * Last reply from: [ValerioCappelli](https://wordpress.org/support/users/valeriocappelli/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/shortcode-javascript/#post-5780871)
 * Status: resolved