YouTube IFrame Player API Failed To Execute PostMessage On DOMWindow
I am trying to load youtube into my web page using YouTube iFrame Player API, and getting following error while loading: Failed to execute 'postMessage' on 'DOMWindow': The target
Solution 1:
Try using loadVideoById
This function loads and plays the specified video.
- The required
videoIdparameter specifies the YouTube Video ID of the video to be played. In the YouTube Data API, avideoresource'sidproperty specifies the ID.- The optional
startSecondsparameter accepts a float/integer. If it is specified, then the video will start from the closest keyframe to the specified time.- The optional
endSecondsparameter accepts a float/integer. If it is specified, then the video will stop playing at the specified time.- The optional
suggestedQualityparameter specifies the suggested playback quality for the video. Please see the definition of thesetPlaybackQualityfunction for more information about playback quality.
Here is a snippet to help you
JS
function searchVideo(){
var vID = document.getElementById("vidID").value
player.loadVideoById(vID, 0, "default");
}
HTML
Search by Video ID: <input type="text" id="vidID" name="vidID"><button onclick="searchVideo()">Search</button>
Post a Comment for "YouTube IFrame Player API Failed To Execute PostMessage On DOMWindow"