代码之家  ›  专栏  ›  技术社区  ›  Donald Roos

添加内容安全策略/Content=default src https后JS不工作:

  •  0
  • Donald Roos  · 技术社区  · 6 年前

    嗨,我的网站工作得很好(bureaudonald.com)。添加后,只有一个JS不再工作 <meta http-equiv="Content-Security-Policy" content="default-src https:">

    function GetValue()
    	{
    		var myarray= new Array(
    			"Why are we doing this?",
    			"Why are we making this?",
    			"Why would we add this?",
    			"etc"
    			);
    	    var random = myarray[Math.floor(Math.random() * myarray.length)];
    	   document.getElementById("message").innerHTML=random;
    	}
    	<!-- WHY -->
    	<div class="main why_loader" id="whysection">	
    	
    		<section data-navlink="navwhy">
    		 
    		<div class="why">
    		
    			<div class="why_content">
    			
    				<div class="why_field">
    					<span class="why_title" id="message">Ask Why!<br/>And Ask it Again<br/>And again</span>
    				</div>								
    			
    				<div class="why_button">
    					<button class="why_btn" onclick="GetValue();">Ask Why Again!</button>
    				</div>
    			
    			</div>
    			<h2>&nbsp;</h2>				
    		</div>
    					
    		</section>
    		
    	</div>
    0 回复  |  直到 6 年前