javascript - HTML OnClick() 事件不起作用

标签 javascript html css button frame

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

此外,我尝试加载 <p></p>来自 XML 文件的文本,但也找不到解决方法。如果有人能帮我找到正确的方法,那就太好了

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>

最佳答案

这看起来像是浏览器缓存问题。尝试以隐身(私有(private))模式打开或使用“Ctrl + F5”硬刷新

关于javascript - HTML OnClick() 事件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47905299/

相关文章:

javascript - 为动态生成的 div 多次调用单击操作

html - 两个div之间的神秘空间

javascript - 谷歌如何在主搜索栏中完成半完成的幽灵文本?

javascript - 绘制形状(N 边形)

javascript - Angular 方法装饰器如何工作?

javascript - 如何通过 Javascript API 检索 linkedin 用户的完整个人资料

javascript - 替换与正则表达式匹配的单元格的内部 html

javascript - 如何在打开后将屏幕阅读器焦点更改为验证模态?

css - Bootstrap-在表单中选择宽度

html - 不同行的不同边框间距