+ 5
Why is this exacly happening?Why isn't the iframe working?
27 Antworten
+ 4
I don't want to leave you stuck, so if you're okay with spoilers:
Changes at your HTML:
6 (import the API)
58+ (swap iframe for a div with an id)
JS tab
HTML line 6 will automatically start function "onYouTubeIframeAPIReady()" at the right time. Here, you can request your video by its YouTube identification, and give it the div's id.
Full spoilers (working code) ...
https://code.sololearn.com/WRIPtzYT5fMD/?ref=app
You can remove the comments; they're fragments for your memory, but not required in the code. I'll delete this if/when you incorporate it.
+ 3
I just adapted this and roughly inserted the video in your code (it worked, so linking so you can do a true fix)
https://code.sololearn.com/WY2xou48ucG4/?ref=app
+ 3
@Kirk Schafer Yo man this is amazing you don'n need to do anything else.Thank you for your time and help bro.So i don't use iframe instead i use the div with the id right so i can add other videos.
+ 3
You'll need a
new YT.Player('id_of_container_div', { ... } )
for each one.
+ 3
You could shorten it to copying 1 line like this (I have stripped the video ready code for clarity):
var allPlayers = []; // array
function addPlayer(divID, vidID) {
allPlayers.push(
new YT.Player(divID, {
height: 150,
width: 300,
videoId : vidID,
})
);
}
function onYouTubeIframeAPIReady() {
addPlayer('csgogasmPlayer', 'xvPHc3bmr2M');
// just add divs, then copy the above line with new ids
}
+ 3
Okay man got it thank you very much for your time it means a lot.
+ 2
ERROR:
Refused to display 'https://www.youtube.com/watch?v=xvPHc3bmr2M&feature=youtu.be' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Long story short, you can't because YouTube doesn't allow you to.
+ 2
Yes how to fix it
+ 2
oh okay bro thanks again.I feel like every time iask something on this app you'll be here lmao.thanks make sure to do that man hit me up.
+ 2
@Kirk Very nice! Didn't realize they had an API for it. Will certainly remember that for myself should I run into an issue of this nature.
+ 2
so I have to repeat this i
over and over again right
+ 1
@CSGO GASM You're more than welcome man. You still owe me a game of CSGO btw. ;) Hit me up this weekend if you're gamin.
+ 1
oh okay my wifi is fucked up right now.
+ 1
Unfortunately, you can't fix that because it's controlled by the other domain, so they would have to allow you to do that. However, you could always download the video and upload it onto your server, then you could easily put the video onto your website and/or iFrame it.
+ 1
hahah sure man I'll see what i can do.did u add me on steam?
+ 1
i dont really need it tho.just testing the page btw what do you think about it?
+ 1
I feel like I did? I haven't been on and gaming lately, so I can't recall. What's your steam name and I can check.
+ 1
My steam name is Bobby skinhub.com bro
+ 1
hit me up in the messages there
+ 1
The page looks great to me bro. If you're just testing iFrames and what not, it's just as easy as creating a fake page on your server and setting it up in the iFrame. Most sites will allow you to do it, but from what I can tell, Google doesn't like people iFraming them. lol
I don't use iFrames that often, but on an intranet website that I created for a company, I use it to access a page that is on another domain/site at one of our other offices, and it's useful because they won't give me access to their server over there. :D Just note that when you don't have access to the other domain, it's limited what you can manipulate in the iFrame, whereas you have full control if it's on your domain (obviously).