Reputation: 15779
I have my 4 static HTML pages created as below.
On each page, there is a link, which opens up another static page called myVideo.html which plays video about me on a new tab.
I have kept that link on each page so that the user can open it up for anywhere.
The problem is, when it opens up from home page, it can again open from about page, so that makes the video autoplay two times which creates a bad impact.
What I want is, when the user has started the video from any page and when they again execute the same from another page, they should get an Alert mentioning that "The video is already being played on a new tab", so that my video plays only once. They can again play the video only on close of the tab which is playing that video.
My question is, is this possible ??
Upvotes: 0
Views: 1230
Reputation: 1099
You can handle this in jquery.
<a href="" title="" target="_blank" onclick="myFunction()" >content</a>
<script>
function myFunction() {
window.open("http://stackoverflow.com","stackoverflow");
}
</script>
Upvotes: -1
Reputation: 17797
Use a target=""
in the link. The target is meant for frames, but when you specify the same target name in every link the browser will open a new tab or window when no window with the name exists, and will reuse the existing window when it exists.
<a href="/link/to/video/" target="video">link</a>
Upvotes: 7
Reputation: 843
Nearly everything is possible.
But this functionnality need some server-side script in my opinion.
The real problem is the impossibility of storing data in a file with JavaScript.
You can detect video events (exemple here: Detect when an HTML5 video finishes) but you're not able to make this information passing through pages.
A JavaScript-only solution will automatically fail when a user will refresh the page, eso...
Upvotes: 0