Jump to content

something like lightbox


Q695
Go to solution Solved by Q695,

Recommended Posts

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?

Link to comment
Share on other sites

  • 1 month later...

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 ....>';

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

  • Solution

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>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.