How can i modify F5 event inside of a iframe?
I want to know how can i get the F5
to use it inside of an iframe
, because i did it but outside of it, in my page. I rewrite the URL of my page with this:
window.history.replaceState({}, '', 'OFRAME');
and when i tried to refresh it i got an error, but i fixed it, with this:
var URLactual = '';
$(document).ready(function () {
if (URLactual == '') {
URLactual = window.parent.location.href;
}
window.history.replaceState({}, '', 'OFRAME');
$(document.body).on("keydown", this, function (event) {
if (event.keyCode == 116) {
window.location.assign(URLactual);
}
});
});
So it works but only in my first page, when navigate inside of the page that contains my iframe
and i press F5
, i don't know why or how but it doesn't read the script
.
After that i press again F5
and the script
works normally but doesn't do what need to do.
javascript iframe refresh
|
show 4 more comments
I want to know how can i get the F5
to use it inside of an iframe
, because i did it but outside of it, in my page. I rewrite the URL of my page with this:
window.history.replaceState({}, '', 'OFRAME');
and when i tried to refresh it i got an error, but i fixed it, with this:
var URLactual = '';
$(document).ready(function () {
if (URLactual == '') {
URLactual = window.parent.location.href;
}
window.history.replaceState({}, '', 'OFRAME');
$(document.body).on("keydown", this, function (event) {
if (event.keyCode == 116) {
window.location.assign(URLactual);
}
});
});
So it works but only in my first page, when navigate inside of the page that contains my iframe
and i press F5
, i don't know why or how but it doesn't read the script
.
After that i press again F5
and the script
works normally but doesn't do what need to do.
javascript iframe refresh
Iframes have their own windows and when focused the events occur in that window with no knowledge of or bubbling to parent window listeners. If iframe is from a different origin than main page (protocol, domain, subdomain or port) you can't access it's window using script from parent unless you control the code in both
– charlietfl
Nov 22 at 20:45
So... is iframe from same origin as page?
– charlietfl
Nov 22 at 20:49
as the page that shows?
– ASpong
Nov 22 at 20:53
Yes...as in main page from example.com and iframe page from example.com
– charlietfl
Nov 22 at 20:54
No it's not :/ So what can i do? could i refresh in other way my iframe? I have access to those pages that my iframe shows
– ASpong
Nov 22 at 20:58
|
show 4 more comments
I want to know how can i get the F5
to use it inside of an iframe
, because i did it but outside of it, in my page. I rewrite the URL of my page with this:
window.history.replaceState({}, '', 'OFRAME');
and when i tried to refresh it i got an error, but i fixed it, with this:
var URLactual = '';
$(document).ready(function () {
if (URLactual == '') {
URLactual = window.parent.location.href;
}
window.history.replaceState({}, '', 'OFRAME');
$(document.body).on("keydown", this, function (event) {
if (event.keyCode == 116) {
window.location.assign(URLactual);
}
});
});
So it works but only in my first page, when navigate inside of the page that contains my iframe
and i press F5
, i don't know why or how but it doesn't read the script
.
After that i press again F5
and the script
works normally but doesn't do what need to do.
javascript iframe refresh
I want to know how can i get the F5
to use it inside of an iframe
, because i did it but outside of it, in my page. I rewrite the URL of my page with this:
window.history.replaceState({}, '', 'OFRAME');
and when i tried to refresh it i got an error, but i fixed it, with this:
var URLactual = '';
$(document).ready(function () {
if (URLactual == '') {
URLactual = window.parent.location.href;
}
window.history.replaceState({}, '', 'OFRAME');
$(document.body).on("keydown", this, function (event) {
if (event.keyCode == 116) {
window.location.assign(URLactual);
}
});
});
So it works but only in my first page, when navigate inside of the page that contains my iframe
and i press F5
, i don't know why or how but it doesn't read the script
.
After that i press again F5
and the script
works normally but doesn't do what need to do.
javascript iframe refresh
javascript iframe refresh
edited Nov 22 at 20:50
asked Nov 22 at 20:39
ASpong
12
12
Iframes have their own windows and when focused the events occur in that window with no knowledge of or bubbling to parent window listeners. If iframe is from a different origin than main page (protocol, domain, subdomain or port) you can't access it's window using script from parent unless you control the code in both
– charlietfl
Nov 22 at 20:45
So... is iframe from same origin as page?
– charlietfl
Nov 22 at 20:49
as the page that shows?
– ASpong
Nov 22 at 20:53
Yes...as in main page from example.com and iframe page from example.com
– charlietfl
Nov 22 at 20:54
No it's not :/ So what can i do? could i refresh in other way my iframe? I have access to those pages that my iframe shows
– ASpong
Nov 22 at 20:58
|
show 4 more comments
Iframes have their own windows and when focused the events occur in that window with no knowledge of or bubbling to parent window listeners. If iframe is from a different origin than main page (protocol, domain, subdomain or port) you can't access it's window using script from parent unless you control the code in both
– charlietfl
Nov 22 at 20:45
So... is iframe from same origin as page?
– charlietfl
Nov 22 at 20:49
as the page that shows?
– ASpong
Nov 22 at 20:53
Yes...as in main page from example.com and iframe page from example.com
– charlietfl
Nov 22 at 20:54
No it's not :/ So what can i do? could i refresh in other way my iframe? I have access to those pages that my iframe shows
– ASpong
Nov 22 at 20:58
Iframes have their own windows and when focused the events occur in that window with no knowledge of or bubbling to parent window listeners. If iframe is from a different origin than main page (protocol, domain, subdomain or port) you can't access it's window using script from parent unless you control the code in both
– charlietfl
Nov 22 at 20:45
Iframes have their own windows and when focused the events occur in that window with no knowledge of or bubbling to parent window listeners. If iframe is from a different origin than main page (protocol, domain, subdomain or port) you can't access it's window using script from parent unless you control the code in both
– charlietfl
Nov 22 at 20:45
So... is iframe from same origin as page?
– charlietfl
Nov 22 at 20:49
So... is iframe from same origin as page?
– charlietfl
Nov 22 at 20:49
as the page that shows?
– ASpong
Nov 22 at 20:53
as the page that shows?
– ASpong
Nov 22 at 20:53
Yes...as in main page from example.com and iframe page from example.com
– charlietfl
Nov 22 at 20:54
Yes...as in main page from example.com and iframe page from example.com
– charlietfl
Nov 22 at 20:54
No it's not :/ So what can i do? could i refresh in other way my iframe? I have access to those pages that my iframe shows
– ASpong
Nov 22 at 20:58
No it's not :/ So what can i do? could i refresh in other way my iframe? I have access to those pages that my iframe shows
– ASpong
Nov 22 at 20:58
|
show 4 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437750%2fhow-can-i-modify-f5-event-inside-of-a-iframe%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437750%2fhow-can-i-modify-f5-event-inside-of-a-iframe%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Iframes have their own windows and when focused the events occur in that window with no knowledge of or bubbling to parent window listeners. If iframe is from a different origin than main page (protocol, domain, subdomain or port) you can't access it's window using script from parent unless you control the code in both
– charlietfl
Nov 22 at 20:45
So... is iframe from same origin as page?
– charlietfl
Nov 22 at 20:49
as the page that shows?
– ASpong
Nov 22 at 20:53
Yes...as in main page from example.com and iframe page from example.com
– charlietfl
Nov 22 at 20:54
No it's not :/ So what can i do? could i refresh in other way my iframe? I have access to those pages that my iframe shows
– ASpong
Nov 22 at 20:58