Why isn't my web page closing after the video? - javascript

It is pretty simple what I am trying to accomplish, but I think my website hates me. It is currently live at;
https://www.eves.website/eve_6.html
except it doesn't close the webpage after the video has finished. Why?
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>eve_</title>
<link rel="icon" rel="preload" href="images/evecircle.png" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript">
$(document).ready(function(){
$("#myVideo").bind('ended', function(){
self.close();
});
});
</script>
</head>
<body>
<video id="myVideo" style="margin-left:-10px; margin-top:-10px;" width="105%" height="105%" autoplay>
<source src="images/death.mp4" autoplay="true" type="video/mp4" />
Your browser does not support the video tag.
</video>
</body>
</html>

How do you open your website? If you are opening by entering the URL in a new tab, it cannot be closed using JavaScript. The way you have put, the script has a requirement that the page to be closed, cannot be the original page.
It must be opened as a new window using JavaScript. If you wish to close a page that has been posted via form, the page must first have still been opened in a separate window using JavaScript.
From MDN for window.close():
In the past, when you called the window object's close() method directly, rather than calling close() on a window instance, the browser closed the frontmost window, whether your script created that window or not. This is no longer the case; for security reasons, scripts are no longer allowed to close windows they didn't open. (Firefox 46.0.1: scripts can not close windows, they had not opened).

If you are opening the site with the script then you can use this
document.getElementById('myVideo').addEventListener('ended',function(){
window.close();
}, false);

Related

How to access embedded openload iframe

I'm trying to get direct download links from embedded openload links (example: https://openload.co/embed/CoKeagPRpQg/). The result might look something like this: https://openload.co/stream/CoKeagPRpQg~1527355595~2a02:120b::~J-XBN0SR?mime=true. If you navigate to the embed link and run
document.querySelector("#mediaspace_wrapper > div:last-child > p:last-child")
from the developer console, the essential data for the stream link is returned. When I tried to implement this on an embedded video on my private site, I got an error for cross site scripting, which is understandable.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Proflix</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<iframe id="video" src="https://openload.co/embed/CoKeagPRpQg/" scrolling="no" frameborder="0" width="700" height="430" allowfullscreen="true"
webkitallowfullscreen="true" mozallowfullscreen="true">
</iframe>
</body>
</html>
However, I stumbled across this chrome extension, which with JavaScript alone can enter the iframe (Demo). This really puzzles me. I contacted the developer and he told me his extention was based on this script. But it didn't work from the developer console. My question is: How can JavaScript enter a foreign iframe in this example and how can I replicate it?
Related:
Get the unique download link on Openload
Get stream URL from openload

how to redirect a web page and show the new URL?

I want to redirect a plain HTML web page to a new URL, but everything I have tried (meta refresh, Javascript redirect) results in the old URL appearing in the address bar of the new page, even after clearing my browser cache. .htaccess redirects sometimes work but are complicated by the fact that the old page is already the target of a redirect from another domain. I do not have access to the hosting account.
Can anybody suggest a way to make the new URL always appear on the address bar for the new page? Thanks a lot.
Using the meta refresh tag should work fine.
<meta http-equiv="refresh" content="0; url=http://example.com/" />
Note: Place it in the head section.
You may also want to do a javascript redirect as the W3C doesn't recommend the meta tag approach, although it may not work on all mobile browsers. Along with a fallback text link, that would make your page similar to:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1; url=http://example.com">
<script type="text/javascript">
window.location.href = "http://example.com"
</script>
<title>Page Redirection</title>
</head>
<body>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow this <a href='http://example.com'>link to example</a>.
</body>
</html>
Many thanks to the answers from this previous answer: Redirect from an HTML page

Error: Audio playback was aborted IE 11 Windows 7

I have folder structure like
Folder interactive_pages_test
C:\Users\username\Desktop\interactive_pages_test\test.html
C:\Users\username\Desktop\interactive_pages_test\2_Hot_Cross_Buns.mp3
Folder test
C:\Users\username\Desktop\test\test.html
C:\Users\username\Desktop\test\2_Hot_Cross_Buns.mp3
The files test.html and 2_Hot_Cross_Buns.mp3 are same. When I opened C:\Users\username\Desktop\interactive_pages_test\test.html in IE 11 it is throwing anError: Audio playback was aborted. But C:\Users\username\Desktop\test\test.html is playing fine in IE. In chrome and Mozilla both of the files are playing fine. Can any one please advice on this issue?
<html>
<head>
<title>Tile</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" >
alert("hi");
</script>
</head>
<body>
<audio src="./2_Hot_Cross_Buns.mp3" controls="">Audio not supported</audio>
</body>
</html>
Actually IE's in Windows 8 are above uses activeX control for playing audios, so when you the html file it prompts that ActiveX control is blocked, if you click on allow blocked content then it will play normally.
Prompt for activex
After Enabling blocked content

window.close not closing window in HTA application

In my HTA application I'm using a JavaScript calendar window, it opens using window.open() and closed using window.close(), when the user clicks on one of the dates. This calendar works fine on multiple browsers and versions over more than 10 years. It even works in HTA applications most of the time.
However on specific workstations running IE11. The window.close() command is simply ignored, resulting in the window left open. On other IE11 workstations it works fine. I figured that turning off the "Enable Protected Mode" checkbox on IE11, Internet Options, Security tab resolves the problem on one of the problematic workstation. However, other workstations works fine with this setting turned on and turning off this setting is not an acceptable solution.
Code sample which reproduces the problem:
HTA application
<HTML>
<HEAD>
<HTA:APPLICATION ID="OpenCloseExample" BORDER="thick" BORDERSTYLE="complex"/>
<TITLE>Open Close HTA container</TITLE>
</HEAD>
<iframe width="1024px" height="768px" src="http://localhost:28080/openclose.html"/>
</HTML>
openclose.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Main Page</title>
<script src="openclose.js"></script>
</head>
<body>
open
</body>
</html>
openclose.js
var win;
function openWindow() {
win = window.open("", "_blank", 'width=250,height=250,status=no,resizable=no,location=no,top=100,left=100');
win.document.writeln("<html><head><script src='openclose.js'></script></head><a href='#' onclick='javascript:window.opener.closeWindow()'>close</a></html>");
}
function closeWindow() {
win.window.close();
}
I can't see this working in any IE with any settings. The problem is this string: <script src='openclose.js'></script>. That is, a literal ending script tag in a string works as an ending script tag on a page, when HTML parser will find it. This means, that your script was never loaded.
To fix this, you've to break the literal tag, for example like so:
<script src='openclose.js'><\/script>
Since you have pointed out that IE11 is causing the JS not to work, you can force IE to render in an older version very easily.
<meta http-equiv="X-UA-Compatible" content="IE=9">
This meta tag is very popular amongst HTA applications for utilizing JS/ActiveX methods/properties within specific IE versions (most of them being deprecated).
For more information, visit the X-UA-Compatible Tag Wiki
Hope this helps
I figured this out eventually.
Changing:
open
to:
open
Has resolved the problem

JavaScript doesn't work with apple-mobile-web-app-capable if add to Home Screen

I made a full-screen web app with <meta name="apple-mobile-web-app-capable" content="yes">. If I add the web page to homescreen, all JavaScript stops working
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta name="apple-mobile-web-app-capable" content="yes">
</head>
<body>
<script type="text/javascript" charset="utf-8">
alert(window.navigator.standalone);
</script>
</body>
</html>
This demo works in Safari, alert false, but if I add the page to Home Screen, then open it from homescreen, no alert, none of the Javascript works. Does anyone know what's wrong with it?
Try to include all the relevant tags in the head section, not only the apple-mobile-web-app-capable.
Alert and Confirm seems to be broken in iOS7 when app is pined to the home screen.
See :
"alert()" and "confirm()" not working with "apple-mobile-web-app-capable"
But javascript is working fine :+)
You try to delete cookie and data in Safari in configuration.

Categories

Resources