Long youtube links

Avatar
p0rtalplayer
1,366 Posts
Posted May 29, 2012
Let's bring this out of the music thread to avoid clutter.

Current status:
- works on firefox, as long as the link doesn't have more than 1 ampersand
- doesn't work on chrome, even though the embed src property is being set (anyone know if chrome does something different with javascript I should I know about?)
- IE: fuck you, this site looks like shit on IE and I don't feel like doing anything about it.

Here's what the code looks like:

[code:1n8jc8w5]
<embed id="ytembed" width="425" height="344"
src="http://www.youtube.com/v/"
type="application/x-shockwave-flash"
allowfullscreen="true">
</embed>
<p id="output">{URL}</p>

<script type="text/javascript">

window.onload=fixYoutube();

function fixYoutube() {
var numEmbeds = document.getElementsByTagName("embed").length;
document.getElementById("ytembed").id="ytembed"+numEmbeds;
document.getElementById("output").id="output"+numEmbeds;

var txt = document.getElementById("output"+numEmbeds).innerHTML;
var vee=0;
var amd=0;
var i=0;
var j=0;

for (i=0;i<=txt.length;i++)
{
if (txt.charAt(i)=="v") { vee=i;}
}
var txt2 = txt.slice(vee + 2,txt.length);
var txt3 = txt2;

for (j=0;j<=txt2.length;j++)
{
if (txt2.charAt(j)=="&") { amd=j; }
else { amd=j; }
}
txt3 = txt2.slice(0,amd);

document.getElementById("ytembed"+numEmbeds).src="http://www.youtube.com/v/"+txt3;
document.getElementById("output"+numEmbeds).innerHTML=" ";
}
</script>
[/code:1n8jc8w5]
(I'm a noob at javascript, if this is terribly inefficient or something cut me some slack)

On chrome, the embed src attribute does get replaced, but its like the browser doesn't realize it, or something. If you look at the page source for anywhere that's used on chrome, it'll show the correct link but the video on the page itself won't be active.

Advertisement
Registered users don't see ads! Register now!
Avatar
Pilchard123
334 Posts
Posted May 29, 2012
Replied 21 minutes later
Yes, Chrome does do stuff differently with JavaScript, I just can't remember what.
Avatar
kizzycocoa
975 Posts
Posted May 29, 2012
Replied 9 minutes later
what about Opera?
Avatar
p0rtalplayer
1,366 Posts
Posted May 29, 2012
Replied 1 hour later
I'll take a look at opera in a bit. Testing something:

[yt:11thnun5]http://www.youtube.com/watch?v=QH2-TGUlwu4&feature=related[/yt:11thnun5]

Okay, seems to work in chrome It bugs out if you have more than one & in the url, I'll try to get to that next.

Let me know if there's any problems still.

Avatar
Termikxs
182 Posts
Posted May 30, 2012
Replied 8 hours later

p0rtalplayer wrote:
Okay, seems to work in chrome

[yt:20fi91em]http://www.youtube.com/watch?v=vWizDna1XO4[/yt:20fi91em]

Avatar
Sven
306 Posts
Posted May 30, 2012
Replied 1 hour later

t3x wrote:

p0rtalplayer wrote:
Okay, seems to work in chrome

[yt:1bbbca85]http://www.youtube.com/watch?v=vWizDna1XO4[/yt:1bbbca85]

I see nothing. (On Firefox)

Avatar
Termikxs
182 Posts
Posted May 30, 2012
Replied 15 minutes later
I see nothing either.
What went wrong?
Avatar
kizzycocoa
975 Posts
Posted May 30, 2012
Replied 28 minutes later
I see a video box with a crossed out play button here. On my iPad, so it's not opera.
Avatar
Pilchard123
334 Posts
Posted May 30, 2012
Replied 7 hours later

Sven wrote:

t3x wrote:

p0rtalplayer wrote:
Okay, seems to work in chrome

[yt:2lknse5z]http://www.youtube.com/watch?v=vWizDna1XO4[/yt:2lknse5z]>
I see nothing. (On Firefox)

Big box of nothing.

Chrome 19.0.1084.52 m

Avatar
Groxkiller585
652 Posts
Posted May 30, 2012
Replied 1 hour later

Pilchard123 wrote:

Big box of nothing.

Chrome 19.0.1084.52 m

Same but on firefox.

Avatar
kizzycocoa
975 Posts
Posted May 30, 2012
Replied 24 minutes later

p0rtalplayer wrote:
I'll take a look at opera in a bit. Testing something:

[yt:15y38yqx]http://www.youtube.com/watch?v=QH2-TGUlwu4&feature=related[/yt:15y38yqx]

Okay, seems to work in chrome It bugs out if you have more than one & in the url, I'll try to get to that next.

Let me know if there's any problems still.

I see this one. but none below it in Opera.

Avatar
p0rtalplayer
1,366 Posts
Posted May 30, 2012
Replied 8 minutes later
Okay guys, thanks for the info, I'll take a look.

t3x wrote:

p0rtalplayer wrote:
Okay, seems to work in chrome

[yt:3b2tep73]http://www.youtube.com/watch?v=vWizDna1XO4[/yt:3b2tep73]

I think the reason this doesn't work is it's got a v in it...I'll revise my url stripping method.

Edit: now it looks for "v=" instead so it shouldn't get any false positives. Seems to be working.

Avatar
kizzycocoa
975 Posts
Posted May 30, 2012
Replied 10 minutes later
now, they all work
Avatar
Termikxs
182 Posts
Posted May 30, 2012
Replied 15 minutes later

p0rtalplayer wrote:
Okay guys, thanks for the info, I'll take a look.

t3x wrote:

p0rtalplayer wrote:
Okay, seems to work in chrome

[yt:bad8o2hx]http://www.youtube.com/watch?v=vWizDna1XO4[/yt:bad8o2hx]>

I think the reason this doesn't work is it's got a v in it...I'll revise my url stripping method.

Edit: now it looks for "v=" instead so it shouldn't get any false positives. Seems to be working.

[yt:bad8o2hx]http://www.youtube.com/watch?v=vWizDna1XO4[/yt:bad8o2hx]

Avatar
Pilchard123
334 Posts
Posted May 30, 2012
Replied 23 minutes later
Everything seems okay here too.
Advertisement
Registered users don't see ads! Register now!