Search code examples
javascripthtmliframejsbin

Get url from updated JSBIN IFRAME


I have an iframe with a jsbin url. When I edit the jsbin, is there any possible way to obtain the upgraded url, without taking it from the jsbin interface.

For example,

I have my iframe with jsbin. I work some stuff on it, and the url of the jsbin changes in order to save my work. How with javascript can I retrieve the upgraded url?

------HTML

<div><iframe id="myframe" class='iframeSize'  src="www.jsbin.com/fafda/1/edit" ></iframe></div>;

------javascript

var updatedLInk = $("#myframe").attr("src");

When I edit the jsbin the link changes because it stores information, however, when I want to retrieve the updatedLInk, I only get the original link like www.jsbin.com/fafda/1/edit instead of www.jsbin.com/fafda/8/edit


Solution

  • You could use <iframe id="myframe" class='iframeSize' src="www.jsbin.com/fafda/latest" >

    in order to always display the latest version of your jsbin.

    Also if at any time you need to figure out the url you can request the latest url i.e. www.jsbin.com/fafda/latest from your server side code (to avoid cross domain issues from client side js) and read the last location redirected.