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

  • SEARCH
  • Home
  • 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 7749041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:56:30+00:00 2026-06-01T10:56:30+00:00

The idea is to write a simple bookmarklet. If the question is a possible

  • 0

The idea is to write a simple bookmarklet.
If the question is a possible duplicate kindly point me to it, because i was unsuccessful in finding.

I’m trying to make the current page jquery enabled using the bookmarklet and use certain jquery apis.

Uncaught SyntaxError: Unexpected token ILLEGAL

The above it the error I get using the below sample bookmarklet

javascript:(function(){
 var d=document.createElement('script');
 d.setAttribute('src', 'http://code.jquery.com/jquery-latest.js');
 document.head.appendChild(d);
 $('a').each(function(){
  alert( $(this).attr('src') );
 });
})()

​ If I execute the same code line-by-line in console it works.

Thanks in advance

  • 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-01T10:56:31+00:00Added an answer on June 1, 2026 at 10:56 am

    To make the page wait until jQuery is fully loaded, add a load handler to the script element. This worked in my browser:

    javascript:(function(){
     var d=document.createElement('script');
     d.src = 'http://code.jquery.com/jquery-latest.js';
     d.onload = function(){ /* load handler here */
       $('a').each(function(){
         console.log( $(this).attr('href') );
       });
     };
     document.getElementsByTagName('head')[0].appendChild(d);
    })()
    

    I changed your code a little bit (add the src attribute directly as property to the created script element, retrieve the head element in a more classical way, use console.log instead of alert and log the href attribute of all links).

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

Sidebar

Related Questions

Any idea how I express 'implements' in UML? I'm trying to write some actionscript
I'm trying to write a simple web interface to allow users to install one
I am trying to write a simple C++ program on an AIX Box. The
I'm trying to do a simple write to database with an HTML form, using
Ive spent 4 hours trying to write a simple insert a datetime into a
im new in PHP and im trying to write simple online shop. Lets say
I'm trying write a simple perl script that reads some fields from a password
I'm trying to write a simple HTTP remember me authentication system for users. My
I'm trying to write a simple generic parallel code for minimizing a function in
I want to write a simple C# console application to change the current directory

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.