Disabling 'allowfullscreen' from the youtube in the javascript












1














To prevent double click fullscreen from the iframe all you do is remove 'allowfullscreen' from the iframe code.



<iframe width="606" height="344" src="https://www.youtube.com/embed/M7lc1UVf-VE" frameborder="0" /*allowfullscreen*/></iframe>


But how would it be done through the youtube javascript api if you’re not using the iframe?



I can’t seem to figure it out



This seems like it would be simple to do but I can't seem to figure it out.



How would this be done?



I've been looking all over and haven't found any code that does this.



Nothing I'm trying seems to be working at all.



If it's able to be done via the iframe, shouldn't it be able to be done through the javascript also?



Also: fs: 0; Doesn't remove Double click fullscreen.



https://jsfiddle.net/zb6mkug3/829/



<div class="player"></div>

(function iife() {
"use strict";
const tag = document.createElement("script");
tag.src = "https://www.youtube.com/player_api";
const firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

function onPlayerReady(event) {
const youtubePlayer = event.target;
youtubePlayer.setVolume(0); // percent
}
window.onYouTubePlayerAPIReady = function() {
new YT.Player(document.querySelector(".player"), {
height: '315',
width: '560',
host: 'https://www.youtube-nocookie.com',
videoId: 'M7lc1UVf-VE',
playerVars: {
controls: 1,
fs: 0,
},
events: {
"onReady": onPlayerReady
}
});
};
}());









share|improve this question





























    1














    To prevent double click fullscreen from the iframe all you do is remove 'allowfullscreen' from the iframe code.



    <iframe width="606" height="344" src="https://www.youtube.com/embed/M7lc1UVf-VE" frameborder="0" /*allowfullscreen*/></iframe>


    But how would it be done through the youtube javascript api if you’re not using the iframe?



    I can’t seem to figure it out



    This seems like it would be simple to do but I can't seem to figure it out.



    How would this be done?



    I've been looking all over and haven't found any code that does this.



    Nothing I'm trying seems to be working at all.



    If it's able to be done via the iframe, shouldn't it be able to be done through the javascript also?



    Also: fs: 0; Doesn't remove Double click fullscreen.



    https://jsfiddle.net/zb6mkug3/829/



    <div class="player"></div>

    (function iife() {
    "use strict";
    const tag = document.createElement("script");
    tag.src = "https://www.youtube.com/player_api";
    const firstScriptTag = document.getElementsByTagName("script")[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

    function onPlayerReady(event) {
    const youtubePlayer = event.target;
    youtubePlayer.setVolume(0); // percent
    }
    window.onYouTubePlayerAPIReady = function() {
    new YT.Player(document.querySelector(".player"), {
    height: '315',
    width: '560',
    host: 'https://www.youtube-nocookie.com',
    videoId: 'M7lc1UVf-VE',
    playerVars: {
    controls: 1,
    fs: 0,
    },
    events: {
    "onReady": onPlayerReady
    }
    });
    };
    }());









    share|improve this question



























      1












      1








      1







      To prevent double click fullscreen from the iframe all you do is remove 'allowfullscreen' from the iframe code.



      <iframe width="606" height="344" src="https://www.youtube.com/embed/M7lc1UVf-VE" frameborder="0" /*allowfullscreen*/></iframe>


      But how would it be done through the youtube javascript api if you’re not using the iframe?



      I can’t seem to figure it out



      This seems like it would be simple to do but I can't seem to figure it out.



      How would this be done?



      I've been looking all over and haven't found any code that does this.



      Nothing I'm trying seems to be working at all.



      If it's able to be done via the iframe, shouldn't it be able to be done through the javascript also?



      Also: fs: 0; Doesn't remove Double click fullscreen.



      https://jsfiddle.net/zb6mkug3/829/



      <div class="player"></div>

      (function iife() {
      "use strict";
      const tag = document.createElement("script");
      tag.src = "https://www.youtube.com/player_api";
      const firstScriptTag = document.getElementsByTagName("script")[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      function onPlayerReady(event) {
      const youtubePlayer = event.target;
      youtubePlayer.setVolume(0); // percent
      }
      window.onYouTubePlayerAPIReady = function() {
      new YT.Player(document.querySelector(".player"), {
      height: '315',
      width: '560',
      host: 'https://www.youtube-nocookie.com',
      videoId: 'M7lc1UVf-VE',
      playerVars: {
      controls: 1,
      fs: 0,
      },
      events: {
      "onReady": onPlayerReady
      }
      });
      };
      }());









      share|improve this question















      To prevent double click fullscreen from the iframe all you do is remove 'allowfullscreen' from the iframe code.



      <iframe width="606" height="344" src="https://www.youtube.com/embed/M7lc1UVf-VE" frameborder="0" /*allowfullscreen*/></iframe>


      But how would it be done through the youtube javascript api if you’re not using the iframe?



      I can’t seem to figure it out



      This seems like it would be simple to do but I can't seem to figure it out.



      How would this be done?



      I've been looking all over and haven't found any code that does this.



      Nothing I'm trying seems to be working at all.



      If it's able to be done via the iframe, shouldn't it be able to be done through the javascript also?



      Also: fs: 0; Doesn't remove Double click fullscreen.



      https://jsfiddle.net/zb6mkug3/829/



      <div class="player"></div>

      (function iife() {
      "use strict";
      const tag = document.createElement("script");
      tag.src = "https://www.youtube.com/player_api";
      const firstScriptTag = document.getElementsByTagName("script")[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      function onPlayerReady(event) {
      const youtubePlayer = event.target;
      youtubePlayer.setVolume(0); // percent
      }
      window.onYouTubePlayerAPIReady = function() {
      new YT.Player(document.querySelector(".player"), {
      height: '315',
      width: '560',
      host: 'https://www.youtube-nocookie.com',
      videoId: 'M7lc1UVf-VE',
      playerVars: {
      controls: 1,
      fs: 0,
      },
      events: {
      "onReady": onPlayerReady
      }
      });
      };
      }());






      javascript youtube-api fullscreen fullscreenchange






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 19:38

























      asked Nov 12 at 19:27









      J Dawg

      448




      448
























          1 Answer
          1






          active

          oldest

          votes


















          0














          In playerVars, simply add fs: 0, that will disable the fullscreen choice:



          playerVars: {
          controls: 1,
          fs: 0
          },


          source






          share|improve this answer























          • That doesn't work. Double click fullscreen is still enabled. It doesn't remove that. I want to remove the double click fullscreen.
            – J Dawg
            Nov 12 at 19:33












          • If you want to disable the doubleclick-fullscreen you'll have to do so in the browser preferences. It's not a Youtube API option, rather than a browser-related thing.
            – McVenco
            Nov 12 at 19:38










          • How come it works by removing 'allowfullscreen' from the iframe? That disables it. Wouldn't there be something that works the same way with the javascript?
            – J Dawg
            Nov 12 at 19:39












          • allowfullscreen is an attribute of iframe. I'm not too familiar with iframe so I had to look it up and found this: developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe. So apparently you'll have to look into Element.requestFullScreen: developer.mozilla.org/en-US/docs/Web/API/Element/…
            – McVenco
            Nov 12 at 19:44










          • This works in Firefox, but not Chrome. jsfiddle.net/zb6mkug3/359 videoPlayer.allowFullscreen = false; But I can't find something that will work with Chrome.
            – J Dawg
            Nov 12 at 19:48













          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268826%2fdisabling-allowfullscreen-from-the-youtube-in-the-javascript%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          In playerVars, simply add fs: 0, that will disable the fullscreen choice:



          playerVars: {
          controls: 1,
          fs: 0
          },


          source






          share|improve this answer























          • That doesn't work. Double click fullscreen is still enabled. It doesn't remove that. I want to remove the double click fullscreen.
            – J Dawg
            Nov 12 at 19:33












          • If you want to disable the doubleclick-fullscreen you'll have to do so in the browser preferences. It's not a Youtube API option, rather than a browser-related thing.
            – McVenco
            Nov 12 at 19:38










          • How come it works by removing 'allowfullscreen' from the iframe? That disables it. Wouldn't there be something that works the same way with the javascript?
            – J Dawg
            Nov 12 at 19:39












          • allowfullscreen is an attribute of iframe. I'm not too familiar with iframe so I had to look it up and found this: developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe. So apparently you'll have to look into Element.requestFullScreen: developer.mozilla.org/en-US/docs/Web/API/Element/…
            – McVenco
            Nov 12 at 19:44










          • This works in Firefox, but not Chrome. jsfiddle.net/zb6mkug3/359 videoPlayer.allowFullscreen = false; But I can't find something that will work with Chrome.
            – J Dawg
            Nov 12 at 19:48


















          0














          In playerVars, simply add fs: 0, that will disable the fullscreen choice:



          playerVars: {
          controls: 1,
          fs: 0
          },


          source






          share|improve this answer























          • That doesn't work. Double click fullscreen is still enabled. It doesn't remove that. I want to remove the double click fullscreen.
            – J Dawg
            Nov 12 at 19:33












          • If you want to disable the doubleclick-fullscreen you'll have to do so in the browser preferences. It's not a Youtube API option, rather than a browser-related thing.
            – McVenco
            Nov 12 at 19:38










          • How come it works by removing 'allowfullscreen' from the iframe? That disables it. Wouldn't there be something that works the same way with the javascript?
            – J Dawg
            Nov 12 at 19:39












          • allowfullscreen is an attribute of iframe. I'm not too familiar with iframe so I had to look it up and found this: developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe. So apparently you'll have to look into Element.requestFullScreen: developer.mozilla.org/en-US/docs/Web/API/Element/…
            – McVenco
            Nov 12 at 19:44










          • This works in Firefox, but not Chrome. jsfiddle.net/zb6mkug3/359 videoPlayer.allowFullscreen = false; But I can't find something that will work with Chrome.
            – J Dawg
            Nov 12 at 19:48
















          0












          0








          0






          In playerVars, simply add fs: 0, that will disable the fullscreen choice:



          playerVars: {
          controls: 1,
          fs: 0
          },


          source






          share|improve this answer














          In playerVars, simply add fs: 0, that will disable the fullscreen choice:



          playerVars: {
          controls: 1,
          fs: 0
          },


          source







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 at 19:33

























          answered Nov 12 at 19:30









          McVenco

          1,01011528




          1,01011528












          • That doesn't work. Double click fullscreen is still enabled. It doesn't remove that. I want to remove the double click fullscreen.
            – J Dawg
            Nov 12 at 19:33












          • If you want to disable the doubleclick-fullscreen you'll have to do so in the browser preferences. It's not a Youtube API option, rather than a browser-related thing.
            – McVenco
            Nov 12 at 19:38










          • How come it works by removing 'allowfullscreen' from the iframe? That disables it. Wouldn't there be something that works the same way with the javascript?
            – J Dawg
            Nov 12 at 19:39












          • allowfullscreen is an attribute of iframe. I'm not too familiar with iframe so I had to look it up and found this: developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe. So apparently you'll have to look into Element.requestFullScreen: developer.mozilla.org/en-US/docs/Web/API/Element/…
            – McVenco
            Nov 12 at 19:44










          • This works in Firefox, but not Chrome. jsfiddle.net/zb6mkug3/359 videoPlayer.allowFullscreen = false; But I can't find something that will work with Chrome.
            – J Dawg
            Nov 12 at 19:48




















          • That doesn't work. Double click fullscreen is still enabled. It doesn't remove that. I want to remove the double click fullscreen.
            – J Dawg
            Nov 12 at 19:33












          • If you want to disable the doubleclick-fullscreen you'll have to do so in the browser preferences. It's not a Youtube API option, rather than a browser-related thing.
            – McVenco
            Nov 12 at 19:38










          • How come it works by removing 'allowfullscreen' from the iframe? That disables it. Wouldn't there be something that works the same way with the javascript?
            – J Dawg
            Nov 12 at 19:39












          • allowfullscreen is an attribute of iframe. I'm not too familiar with iframe so I had to look it up and found this: developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe. So apparently you'll have to look into Element.requestFullScreen: developer.mozilla.org/en-US/docs/Web/API/Element/…
            – McVenco
            Nov 12 at 19:44










          • This works in Firefox, but not Chrome. jsfiddle.net/zb6mkug3/359 videoPlayer.allowFullscreen = false; But I can't find something that will work with Chrome.
            – J Dawg
            Nov 12 at 19:48


















          That doesn't work. Double click fullscreen is still enabled. It doesn't remove that. I want to remove the double click fullscreen.
          – J Dawg
          Nov 12 at 19:33






          That doesn't work. Double click fullscreen is still enabled. It doesn't remove that. I want to remove the double click fullscreen.
          – J Dawg
          Nov 12 at 19:33














          If you want to disable the doubleclick-fullscreen you'll have to do so in the browser preferences. It's not a Youtube API option, rather than a browser-related thing.
          – McVenco
          Nov 12 at 19:38




          If you want to disable the doubleclick-fullscreen you'll have to do so in the browser preferences. It's not a Youtube API option, rather than a browser-related thing.
          – McVenco
          Nov 12 at 19:38












          How come it works by removing 'allowfullscreen' from the iframe? That disables it. Wouldn't there be something that works the same way with the javascript?
          – J Dawg
          Nov 12 at 19:39






          How come it works by removing 'allowfullscreen' from the iframe? That disables it. Wouldn't there be something that works the same way with the javascript?
          – J Dawg
          Nov 12 at 19:39














          allowfullscreen is an attribute of iframe. I'm not too familiar with iframe so I had to look it up and found this: developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe. So apparently you'll have to look into Element.requestFullScreen: developer.mozilla.org/en-US/docs/Web/API/Element/…
          – McVenco
          Nov 12 at 19:44




          allowfullscreen is an attribute of iframe. I'm not too familiar with iframe so I had to look it up and found this: developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe. So apparently you'll have to look into Element.requestFullScreen: developer.mozilla.org/en-US/docs/Web/API/Element/…
          – McVenco
          Nov 12 at 19:44












          This works in Firefox, but not Chrome. jsfiddle.net/zb6mkug3/359 videoPlayer.allowFullscreen = false; But I can't find something that will work with Chrome.
          – J Dawg
          Nov 12 at 19:48






          This works in Firefox, but not Chrome. jsfiddle.net/zb6mkug3/359 videoPlayer.allowFullscreen = false; But I can't find something that will work with Chrome.
          – J Dawg
          Nov 12 at 19:48




















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268826%2fdisabling-allowfullscreen-from-the-youtube-in-the-javascript%23new-answer', 'question_page');
          }
          );

          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







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python