How can I pass URL query parameters to a jsFiddle?
Asked Answered
W

5

10

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);
Winsome answered 13/5, 2013 at 17:41 Comment(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 frameHalm
L
2

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.

Lanceolate answered 30/12, 2023 at 8:24 Comment(0)
C
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

Contrasty answered 24/5, 2015 at 18:46 Comment(1)
The example is returning a 404: i.imgur.com/E9lWXRV.pngLanceolate
E
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.

Engel answered 25/6, 2014 at 12:18 Comment(2)
For me this does not work anymore (but it did before!). @Engel Could you double check please?Cutie
This no longer seems to work, but @myriacl's answer from 5/24/2015 still does.Humdrum
H
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.

Hawkbill answered 13/5, 2013 at 20:11 Comment(2)
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.Winsome
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/syhFTHawkbill
C
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).

Cutie answered 15/10, 2014 at 11:45 Comment(2)
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?Smalltime
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".Cutie
L
2

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.

Lanceolate answered 30/12, 2023 at 8:24 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.