11

How can I pass URL query parameters to a jsFiddle? I tried http://jsfiddle.net/mKwcF/?id=123 but all I get is http://fiddle.jshell.net/mKwcF/show/

My example js is simple on a given link above:

alert(window.location.href);
1
  • there are frames going on, I'd guess the window.location.href is the frame. Try window.top or window.top.top or some variation thereof to get out of the frame Commented May 13, 2013 at 18:02

5 Answers 5

7

Actually, the solution is pretty simple and does not involve any Chrome Plugin.

Just access top.location.search when using the domain name fiddle.jshell.net :

Working example : http://fiddle.jshell.net/techp9/hfpx9zh5/1/show/light/?test=1

Sign up to request clarification or add additional context in comments.

1 Comment

The example is returning a 404: i.imgur.com/E9lWXRV.png
4

All you need is to add show at the end of the URL and then add query

e.g:

if your jsFiddle URL is

.../ishaiborovoy/Yx9P899/123/

then you should refer to:

.../ishaiborovoy/Yx9P6/123/show?myFirstParam=1&mySecondParam=2.

This works for me.

2 Comments

For me this does not work anymore (but it did before!). @Ishai Could you double check please?
This no longer seems to work, but @myriacl's answer from 5/24/2015 still does.
3

The jsFiddle devs have said it currently isn't possible:

Apart for the original request for this feature we had no other such requests in 12 years, so it's not on the priority list I'm afraid.

Comments

3

As of October 2014 it is a little more complicated than it used to be:

If your jsfiddle url is: 

http://jsfiddle.net/u7G7n/44

use instead (including some url parameters):

http://fiddle.jshell.net/u7G7n/44/show/light/?lat1=52&lng1=9&lat2=50&lng2=1

AND send the same url (including parameters) as referer. You can use Referer Control as Chrome plugin: https://chrome.google.com/webstore/detail/referer-control/hnkcfpcejkafcihlgbojoidoihckciin

And configure like this: enter image description here

Now the second link (including parameters) should work.

EDIT: Plugin RefControl works well for Firefox: http://www.stardrifter.org/refcontrol/ Configure with "fiddle.jshell.net" as site, then choose "Forge" (substitute with root address).

2 Comments

can you explain why we need to interfere with the referer? how jsfiddle ignores the query parameters from browser's address? why does it work as expected when i click on a link vs copy pasting it?
A referer tells the destination page from where you were coming. When you type a URL this does not work. About jsfiddle ignoring query parameters: I guess they do not want people to pass parameters to fiddles from outside. They probably actively check the referer and only allow parameters if they are coming from "inside".
3

I was just trying to figure out the same thing and ran across this in the jsFiddle documentation.

Note: If you want to use a dynamic resource please add a dummy GET variable i.e. http://example.com/dynamically.php?somevar=somevalue&dummy=.css. This will trick jsFiddle to recognize it as CSS resource.

2 Comments

Hi Brian: can you update my fiddle and show how this works when you add a dummy variable - how do I access it? Btw, I found this (github.com/jsfiddle/jsfiddle-issues/issues/176) is still an open issue in jsFiddle.
To be honest I'm not sure if this is going to be of any real help, but of course I always hope for the best. I looked at it a little more last night and was able to make very minor progess. I'm able to get and set the dropdown value. I would expect something similar could be done with the link, maybe putting some javascript in to get some variable and pass that in at the end of the URL. I am still searching though. Here is the link: jsfiddle.net/syhFT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.