Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8074459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:39:19+00:00 2026-06-05T14:39:19+00:00

I am trying to build a simple Bookmarklet that will load some external Javascript

  • 0

I am trying to build a simple Bookmarklet that will load some external Javascript into a page, the goal is to add a markdown editor like Stackoverflow has to another site. I have it working but it requires me to click my Bookmarklet button 2 times instead of 1 time.

The first click gives this error…

Uncaught ReferenceError: Markdown is not defined init.js:46

Line 46 is this…

var converter1 = Markdown.getSanitizingConverter();

Now after clicking my Bookmarklet for the 2nd time then everything runs perfectly but always the first click will give that error and do nothing.

Here is the code for the Bookmarklet file, please help me to fix, my Javascript skills are not too great.

Load external JS and CSS files

function loadScripts(scriptURL) {
    var scriptElem = document.createElement('SCRIPT');
    scriptElem.setAttribute('language', 'JavaScript');
    scriptElem.setAttribute('src', scriptURL);
    void(document.body.appendChild(scriptElem));
}

// Load these 3 Javascript files into the page
// jQuery is already loaded into the page being used so no need to load it
loadScripts('http://codedevelopr.com/labs/javascript/forrst/Markdown.Converter.js');
loadScripts('http://codedevelopr.com/labs/javascript/forrst/Markdown.Sanitizer.js');
loadScripts('http://codedevelopr.com/labs/javascript/forrst/Markdown.Editor.js');

// Load the CSS file into the Page
var head = document.getElementsByTagName('head')[0];
$(document.createElement('link')).attr({
    type: 'text/css',
    href: 'http://codedevelopr.com/labs/javascript/forrst/demo.css',
    rel: 'stylesheet'
}).appendTo(head);

After the files are loaded then we run this…

// Find and replace the curent textarea with the HTML we
// need for our markdown editor to work 
$(document).ready(function () {
    var htmlToReplace = ' \
  <div class="wmd-panel"> \
    <div id="wmd-button-bar"></div> \
      <textarea class="wmd-input" id="wmd-input" name="description"></textarea> \
  </div> \
  <div id="wmd-preview" class="wmd-panel wmd-preview"></div>';

    $("#description").replaceWith(htmlToReplace);

    //Run the Markdown editor!
    var converter1 = Markdown.getSanitizingConverter();

    var editor1 = new Markdown.Editor(converter1);
    editor1.run();

});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:39:20+00:00Added an answer on June 5, 2026 at 2:39 pm

    Your script files are not loaded yet at the time you’re using markdown. You’ve merely sent the requests. You have to wait until the response is received and parsed.

    I’ve cleaned your code up a bit as well as you’re using jQuery:

    var urls = [
      'http://codedevelopr.com/labs/javascript/forrst/Markdown.Converter.js',
      'http://codedevelopr.com/labs/javascript/forrst/Markdown.Sanitizer.js',
      'http://codedevelopr.com/labs/javascript/forrst/Markdown.Editor.js'
    ];
    
    // map urls to getScript calls, and pass them to $.when
    $.when.apply($, $.map(urls, $.getScript)).then(function() {
      // use markdown here
    });
    
    $("<link>", {
      href: 'http://codedevelopr.com/labs/javascript/forrst/demo.css',
      rel: 'stylesheet'
    }).appendTo("head");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a simple RDLC report that shows some data, and has
I am trying to build a simple GUI app in java that will show
I am trying to build a simple web page that has access to my
I am trying to build a simple Composition pattern sample. Basically the output will
I'm trying to build a simple Magento Module that needs to connect to the
I'm trying to build a simple jquery plugin that can take selectors as parameters.
I am trying to build a simple calculator to learn javascript/jquery but seem to
I am trying to build a simple worker function that takes a config of
Im trying to build a simple AJAX script that uses a form to send
I am trying to build a simple phonebook in cakephp 2.0 that stores &

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.