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 215489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:28:30+00:00 2026-05-11T18:28:30+00:00

I have a pretty typical bookmarklet code that’s working perfectly for me in all

  • 0

I have a pretty typical bookmarklet code that’s working perfectly for me in all browsers.
However, when I take this code and put it in an HTML’s element onClick handler, it doesn’t work in IE (6, 7, or 8).

This is the code:

javascript: (
    function(){
        function l(i,u){
            var d=document;
            var s;
            try{
                s=d.standardCreateElement('script');
            }catch(e){}
            if(typeof(s)!='object')
                s=d.createElement('script');
            try{
                s.type='text/javascript';
                s.src='http://{Domain}/bk/' + u;
                s.id='s_' + i;
                d.getElementsByTagName('head')[0].appendChild(s);
            }catch(e){
            }
        }
        AppD = '{Domain}';          
        l('b', 'bk.js');
    }   
    )();

Compressed down as a bookmarklet, that looks like:

javascript:function(){function l(i,u){var d=document;var s;try{s=d.standardCreateElement('script');}catch(e){} if(typeof(s)!='object')  s=d.createElement('script'); try{s.type='text/javascript';s.src='http://{Domain}/bk/' + u;s.id='s_' + i;d.getElementsByTagName('head')[0].appendChild(s);}catch(e){}}AppD = '{Domain}';l('b', 'bk.js');})();

And that works perfectly.
I’ve taken out the javascript: prefix, and put it into an element’s onClick:

<img onclick="function(){function l(i,u){var d=document;var s;try{s=d.standardCreateElement('script');}catch(e){} if(typeof(s)!='object')   s=d.createElement('script'); try{s.type='text/javascript';s.src='http://{Domain}/bk/' + u;s.id='s_' + i;d.getElementsByTagName('head')[0].appendChild(s);}catch(e){}}AppD = '{Domain}';l('b', 'bk.js');})();" />

And that works well too, except than in IE, the code inside bk.js (the script that gets injected) complains that variable AppD is not defined…

Any ideas why this is happening?
Is there any limitation to the code one can put in an onClick handler?

Thanks!
Daniel

  • 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-05-11T18:28:30+00:00Added an answer on May 11, 2026 at 6:28 pm

    Solved by adding window.AppD in front of the variable declaration.

    Solution provided by Andrew Noyes in another question:

    Are there any limitations to what can be done in an inline onclick handler?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 192k
  • Answers 192k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer XML::Simple can do this easily: ## make sure that there… May 12, 2026 at 6:19 pm
  • Editorial Team
    Editorial Team added an answer In theory: One way to discriminate between cartoon and natural… May 12, 2026 at 6:19 pm
  • Editorial Team
    Editorial Team added an answer A better solution is probably to use a decorator, eg:… May 12, 2026 at 6:19 pm

Related Questions

I have a pretty typical bookmarklet code that's working perfectly for me in all
In a pretty typical scenario, I have a 'Search' text box on my web
I have been using the ASP.NET AJAX UpdatePanel control a lot lately for some
I have a pretty simple JPA @ManyToMany relationship set up in my application. A
I have these container objects (let's call them Container) in a list. Each of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.