HTML OnClick()事件不起作用

问题描述 投票:-1回答:1

它一直工作,直到我添加document.getElementById("frame").src="https://www.youtube.com/embed/"+frm;线但现在即使我删除这部分所以使代码像以前一样,并且工作正常,它仍然无法正常工作。我不知道为什么会这样。这可能是我现在想念的一个小细节。有什么想法可以找到它是什么?

此外,我试图从XML文件加载<p></p>文本,但也找不到相应的方法。如果有人能帮我找到合适的方法,那就太好了

function bgClicked2 (idJ,pg,frm)
{
	var id = document.getElementById("bgMAIN");
	id.src="Pics/bgCLICKED2.png";
	var id2=document.getElementById("previews");
	id2.style.visibility="visible";
	document.getElementById("planet").src="Pics/"+idJ+".png";
  document.getElementById("frame").src="https://www.youtube.com/embed/"+frm;
		
}

function bgClicked()
{
	var id,prg,frame;
	id=document.activeElement.id;
	frame=document.activeElement.name;

	bgClicked2(id,"j",frame);
	alert("ughjnj");
	loadXMLDoc();
}
p, li{
	font-size:17px;
	font-style:normal;
	color:#066;
	position:relative;
	float:right;
	word-wrap:break-word;
	width:651px;
	margin-left:35px;	
	
}
.button{
	position:absolute;
	margin-left:453px;
	margin-top:315px;
	z-index:2;
	border-radius:50%;
	border:none;
	size:50px;
	width:83px;
	height:89px;
	opacity:0;
}
<center>
		<div class="upper"><img src="Pics/logo.png" width="75%" height="75%"/></div>
        <!--//<div><img src="Pics/2_.png" style="right:9px; top:12 position:relative;" /></div>-->
         <div class="spaceBoard">
        <input type="button" class="button"  onclick="bgClicked() 	" id="sun" name="piuKlpJmjfg"/>
        <input type="button" class="world" onclick="j()" id="earth" name="pm7tfLvHmXA">
    	<img src="Pics/bgMAIN2.png" id="bgMAIN">  
        	<span id="previews" class="previews">
            	<img src="Pics/sun.png" width="255" height="255" id="planet"/>
                <img src="Pics/back.png" width="39" height="39" style="float:right; margin-left:11" id="btnOut"/>
                <table style="float:right">
                <tr>
            	 <th><p id="paragraph">The sun is a star, a hot ball of glowing gases at the heart of our solar system. Its influence extends far beyond the orbits of distant Neptune and Pluto. Without the sun's intense energy and heat, there would be no life on Earth. And though it is special to us, there are billions of stars like our sun scattered across the Milky Way galaxy. If the sun were as tall as a typical front door, the Earth would be the size of a U.S. nickel. The temperature at the sun's core is about 27 million degrees Fahrenheit. Average diameter: 864,000 miles, about 109 times the size of the Earth.Rotation period at equator: About 27 days. Rotation period at poles: About 36 days. Surface temperature: 10,000 degrees Fahrenheit.Composition: Hydrogen, helium.</p></th>
                 </tr>
                 <tr>
                 	<th><iframe id="frame" width="651" height="405" src="https://www.youtube.com/embed/piuKlpJmjfg" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe></th>
                 </tr>
                 </table>
            	
       	 	</span>
        </div>
javascript html css button frame
1个回答
1
投票

这看起来像浏览器缓存问题。尝试在隐身(私人)模式下打开或使用“Ctrl + F5”进行硬刷新

© www.soinside.com 2019 - 2024. All rights reserved.