Jump to content


Photo

something like lightbox


Best Answer Q695, 18 December 2013 - 04:54 AM

The values of the button should be:

<input type='button' onclick='show_video(w3c, w3c.org)' value='Watch'>

It really outputs:


	function show_video(, )
	{
	document.getElementById('video').innerHTML='$';
	document.getElementById('video').href='$';
	document.getElementById('video').target='_blank';
	}
	</script>
Go to the full post


  • Please log in to reply
7 replies to this topic

#1 Q695

Q695

    Advanced Member

  • Members
  • PipPipPip
  • 703 posts
  • LocationEarth

Posted 02 November 2013 - 07:14 PM

I have this line of code, but it's redirecting to another page, but I want it to replace the freeze frame of the video:

document.write("<iframe width='420' height='315' src='//www.youtube.com/embed/...' frameborder='0' allowfullscreen></iframe>")

What does the document.write need to say to swap, and not go to another page?


if ($problem==mark_solved){

solution ($problem);}

 

if ($skill_level==learning && $my_knowledge==the_required_level_of_knowledge){

     echo "I will try to help, because you're still $skill_level , and my skill level is at $my_knowledge";

} else {

     echo "I can't help you, go away.";

}


#2 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 2,100 posts

Posted 03 November 2013 - 06:21 AM

The document.write is adding an iframe to the webpage. It is the requesting the webpage you have defined in the src attribute (  src='//www.youtube.com/embed/...').



#3 Q695

Q695

    Advanced Member

  • Members
  • PipPipPip
  • 703 posts
  • LocationEarth

Posted 04 November 2013 - 09:42 PM

Yes, but it's going to its own page, but I want to trigger the video to load in the current page similar how a mssenger updates when you send an im to the server, but on the client side as a click..


if ($problem==mark_solved){

solution ($problem);}

 

if ($skill_level==learning && $my_knowledge==the_required_level_of_knowledge){

     echo "I will try to help, because you're still $skill_level , and my skill level is at $my_knowledge";

} else {

     echo "I can't help you, go away.";

}


#4 Q695

Q695

    Advanced Member

  • Members
  • PipPipPip
  • 703 posts
  • LocationEarth

Posted 12 December 2013 - 07:08 AM

Any ideas?


if ($problem==mark_solved){

solution ($problem);}

 

if ($skill_level==learning && $my_knowledge==the_required_level_of_knowledge){

     echo "I will try to help, because you're still $skill_level , and my skill level is at $my_knowledge";

} else {

     echo "I can't help you, go away.";

}


#5 nogray

nogray

    Advanced Member

  • Members
  • PipPipPip
  • 930 posts
  • LocationSan Francisco CA

Posted 12 December 2013 - 02:58 PM

If you use document.write after the page has loaded, it will rewrite the entire page. Instead, use innerHTML of an html element.

 

e.g.

<div id="my_video_div"></div>

... later in your script ...

document.getElementById('my_video_div').innerHTML = '<iframe ....>';


NoGray.com


#6 Q695

Q695

    Advanced Member

  • Members
  • PipPipPip
  • 703 posts
  • LocationEarth

Posted 14 December 2013 - 05:43 AM

I think I can figure it out now :D


if ($problem==mark_solved){

solution ($problem);}

 

if ($skill_level==learning && $my_knowledge==the_required_level_of_knowledge){

     echo "I will try to help, because you're still $skill_level , and my skill level is at $my_knowledge";

} else {

     echo "I can't help you, go away.";

}


#7 Q695

Q695

    Advanced Member

  • Members
  • PipPipPip
  • 703 posts
  • LocationEarth

Posted 15 December 2013 - 04:22 AM

Now I have this code:

<script>
<?php
if ($_GET['item']){
	echo "
	function show_video($video_name, $video_value)
	{
	document.getElementById('video').innerHTML='$video_name';
	document.getElementById('video').href='$video_value';
	document.getElementById('video').target='_blank';
	}
	";
}


?>
</script>

errors as undefined php variables.

 

After this I will rewrite it to swap an image (1st) with a video (2nd).


if ($problem==mark_solved){

solution ($problem);}

 

if ($skill_level==learning && $my_knowledge==the_required_level_of_knowledge){

     echo "I will try to help, because you're still $skill_level , and my skill level is at $my_knowledge";

} else {

     echo "I can't help you, go away.";

}


#8 Q695

Q695

    Advanced Member

  • Members
  • PipPipPip
  • 703 posts
  • LocationEarth

Posted 18 December 2013 - 04:54 AM   Best Answer

The values of the button should be:

<input type='button' onclick='show_video(w3c, w3c.org)' value='Watch'>

It really outputs:


	function show_video(, )
	{
	document.getElementById('video').innerHTML='$';
	document.getElementById('video').href='$';
	document.getElementById('video').target='_blank';
	}
	</script>

if ($problem==mark_solved){

solution ($problem);}

 

if ($skill_level==learning && $my_knowledge==the_required_level_of_knowledge){

     echo "I will try to help, because you're still $skill_level , and my skill level is at $my_knowledge";

} else {

     echo "I can't help you, go away.";

}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com