1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 08:04:49 +01:00

framed replay fixes: don't use 'window.frames[0]' but get framed by 'replay_iframe' id to allow

for custom placement, multiple frames, etc...

ensure outer frame url is updated to canonical (no mod) form for inverse setup as well.
This commit is contained in:
Ilya Kreymer 2015-04-17 21:51:40 -07:00
parent 578323da8a
commit 8bd8485b5a
2 changed files with 11 additions and 7 deletions

View File

@ -23,6 +23,7 @@ var TS_REGEX = /\/([\d]{1,14})\//;
var curr_state = {};
var IFRAME_ID = "replay_iframe";
function make_url(url, ts, mod)
{
@ -38,8 +39,9 @@ function make_url(url, ts, mod)
}
function push_state(url, timestamp, request_ts, capture_str, is_live) {
if (window.frames[0].WB_wombat_location) {
var curr_href = window.frames[0].WB_wombat_location.href;
var frame = document.getElementById(IFRAME_ID).contentWindow;
if (frame.WB_wombat_location) {
var curr_href = frame.WB_wombat_location.href;
// If not current url, don't update
if (url != curr_href) {
@ -56,8 +58,9 @@ function push_state(url, timestamp, request_ts, capture_str, is_live) {
state.capture_str = capture_str;
state.is_live = is_live;
if (wbinfo.replay_mod == "") {
window.history.replaceState(state, "", state.inner_url);
var canon_url = make_url(url, state.request_ts, "");
if (window.location.href != canon_url) {
window.history.replaceState(state, "", canon_url);
}
set_state(state);
@ -66,7 +69,8 @@ function push_state(url, timestamp, request_ts, capture_str, is_live) {
function pop_state(state) {
set_state(state);
window.frames[0].src = state.inner_url;
var frame = document.getElementById(IFRAME_ID).contentWindow;
frame.src = state.inner_url;
}
function extract_ts(url)
@ -131,7 +135,7 @@ function iframe_loaded(event) {
var request_ts;
var capture_str;
var is_live = false;
var iframe = window.frames[0];
var iframe = document.getElementById(IFRAME_ID).contentWindow;
if (iframe.WB_wombat_location) {
url = iframe.WB_wombat_location.href;

View File

@ -30,7 +30,7 @@ html, body
</head>
<body style="margin: 0px; padding: 0px;">
<div class="wb_iframe_div">
<iframe src="{{ wbrequest.wb_prefix + embed_url }}" onload="iframe_loaded(event);" seamless="seamless" frameborder="0" scrolling="yes" class="wb_iframe"/>
<iframe id="replay_iframe" src="{{ wbrequest.wb_prefix + embed_url }}" onload="iframe_loaded(event);" seamless="seamless" frameborder="0" scrolling="yes" class="wb_iframe"/>
</div>
</body>
</html>