javascript - Making iFrames More Usable -
so client of mine has signed ticketing company have convinced them go solution embeds system on client's website via iframe. yuk.
this means on client's events page, they'll navigating through events in iframe , parent's url never change.
i'm wondering if there's can make particular problem less of problem. e.g. on each page load in iframe, send parent's url identifies page of iframe open? way if shares url, or refreshes via browser, they're not left @ starting page in iframe.
i can javascript file of own added iframe, not sure how else manipulate iframe.
any suggestions awesome.
thanks!
you can listen onload-event of iframe , current url of page inside.
var iframe = document.getelementbyid("myframe"); // that's our iframe iframe.addeventlistener("load", function() { var currenturl = iframe.contentdocument.url; // current url of page inside iframe });
you can need url. can change url in browsers url bar window.history
.
// inside onload-event of iframe window.history.pushstate({}, "", "?framepage=" + currenturl.split("/").pop());
this change url everytime user changes location inside iframe, or more precise, adds url parameter. let's user navigates http://example.com/somepage/whatever.html. url in browser have url parameter ?framepage=whatever.html. can make page load page provided in url parameter on first load, people can share these links , iframe has right src.
what store , how store , react you. don't know how page , page inside frame work. last steps example provide 1 possibility. hope can build on this.
Comments
Post a Comment