Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  7] [ 3]  / answers: 1 / hits: 5094  / 10 Years ago, tue, july 29, 2014, 12:00:00

So I have a javascript file that works and is triggered by an html button. The problem is, I am trying to make it so that, when the button is clicked, the game will appear inside an iframe window. How can this be achieved?



HTML:



<input id=clickThis type=button value=JavaScript Game onclick=this.disabled='disabled'; target=jsgame; thatFunction(); />     
<iframe name=jsgame id=jsgame width=700px height=700px> </iframe>

More From » html

 Answers
4

You have a problem in your html code (related to ' and ) , change you button code to this :



<input id=clickThis type=button value=JavaScript Game onclick=this.disabled='disabled'; target='jsgame'; thatFunction(); />    


Than define the javascript function thatFunction that loads your page inside the iframe like this



<script type=text/javascript>
function thatFunction()
{
document.getElementById(jsgame).setAttribute(src,frame.php);
}
</script>


or this code , because I noticed you're assigning the id of the iframe to the javascript variable target



<script type=text/javascript>
function thatFunction()
{
document.getElementById(target).setAttribute(src,frame.php);
}
</script>

[#43526] Sunday, July 27, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yosefleod

Total Points: 113
Total Questions: 100
Total Answers: 115

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
;