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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:33:05+00:00 2026-05-26T03:33:05+00:00

First, check out my fiddle fiddle jsFiddle is nice, but sometimes it runs a

  • 0

First, check out my fiddle fiddle

jsFiddle is nice, but sometimes it runs a bit slow, so I made this simple pure JS fiddle (can be ran locally)

Working great so far, but I want to be able to use jQuery in my fiddle. Type alert(typeof $); in the bottom left box and press “Run” to see what I mean (says undefined).

So how do I pass jQuery off to the iframe and give it the correct context? I suspect I could set doc.contentWindow.$=$ or something like that, but I still need to give the correct context so it knows where to find the elements. How would I do that?


iframe.contentWindow.$ = $.proxy($,iframe.contentWindow);

That didn’t work either. Gives me access to jQuery, but the context is still wrong.


iframe.contentWindow.$ = function(s){return $(s,doc);};

That sort of works… but it’s a bit of a hack.

  • 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-26T03:33:06+00:00Added an answer on May 26, 2026 at 3:33 am

    Why not do as jsfiddle itself does? It simply includes a script tag for jQuery (or whatever framework you asked for) in the head of the iframe.

    If you look in head of the… uh “outer” iframe (the one jsfiddle created), you’ll see they just threw this in there:

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.js"></script>
    

    Same thing applies to the “on ready” and “on load” options, jsfiddle just wraps the appropriate call around your javascript before injecting it into the iframe.

    Modifying your code a little, you can create a script element:

    var doc = iframe.contentWindow.document;
    var jqueryTag = doc.createElement('script');
    jqueryTag.type = 'text/javascript';
    jqueryTag.src = 'http://code.jquery.com/jquery-1.6.4.js';
    

    and then append that element to the head.

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

Sidebar

Related Questions

check out this fiddle: http://jsfiddle.net/5rmEe/61/ var inputVal = false; //allow user to deselect a
Check out this jsfiddle . I'm using the nested sortable plugin, but for some
First check out this code. I seems like it should work for me, but
So this question will get technical – eventually – but first check out Hanselminutes
If you check out this JS fiddle: http://jsfiddle.net/DE5Bp and try to sort the Tariff
for better understanding check out this link first: http://sxsw.usehipster.com/questions/where-are-the-best-breakfast-tacos-in-austin as you can see there,
First of all,check out this image Gmail uses this image to display the animated
First of all I know this is a duplicated question and I check out
Check out my fiddle to see what I'm working with: http://jsfiddle.net/ETKYj/7/ It expands the
Please check out this example, first in FF, Chrome or Safari: [demo link removed]

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.