0

I want to make a video site. Where Users can play video. But the problem is when users want to play video they need to subscribe my youtube channel then they can play videos. I made a modal when users click on play video the modal will ask to subscribe my channel. Now i need that when users subscribe my channel they will redirect to the video page and they can play the videos.

Anyone can help me about it...

html code is here

<h2>Bottom Modal</h2>
<!-- Trigger/Open The Modal -->

<button id="myBtn">Open Modal</button>

<!-- The Modal -->

<div id="myModal" class="modal">
<!-- Modal content -->
 <div class="modal-content">
  <div class="modal-header">
   <h2>Modal Header</h2>
  </div>
  <div class="modal-body">
   <h2>Verify By Subscribing Us</h2>
   <button onclick="myFunction()">Subscribe</button><br><br>
  </div>
  <div class="modal-footer">
   <input type="submit" value="Confirm Subscription" class="confirm">
  </div>
 </div>

</div>

The modal js code is here

// Get the modalM
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("confirm")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
    modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
        modal.style.display = "none";
    }
}
function myFunction() {
    var myWindow = window.open("https://www.youtube.com/channel/UCODLiqqTQZcQxiBLNeeFqDw?sub_confirmation=1", "MsgWindow", "width=600,height=800");
}
  • You need to access youtube's api which will return you true if user is subscribed to your channel or not. – Aleksandar Đokić Aug 14 '16 at 00:25
  • 1
    Possible duplicate of [YouTube API v3 detect if subscribed to a channel](http://stackoverflow.com/questions/22845622/youtube-api-v3-detect-if-subscribed-to-a-channel) – Aleksandar Đokić Aug 14 '16 at 00:25
  • you'll probably need to look into some google supplied youtube API so you can detect if a user is subscribed to your channel or not – Jaromanda X Aug 14 '16 at 00:25

0 Answers0