2013-06-23 3 views
0

다음 스크립트는 내 웹 페이지에 업로드 할 때 작동하지 않습니다. 그것은 잘 작동하고 w3school.com에서 'TryIt Editor'에서 시도해 보면 url을로드합니다. 이 예에서 도메인 이름을 변경했습니다.내 웹 사이트에서 Java 스크립트가 작동하지 않습니다.

<!DOCTYPE html> 
<html> 
<body> 

    <script type='text/javascript'> 
     var x=1; 
     function changeLink() 
     { 
      x=x+1; 
      var y="http://example.com/basicone/image"+x+".html"; 
      document.getElementById('iframe-a').src=y; 
     } 
    </script> 

    <iframe id="iframe-a" seamless src="http://example.com/basicone/image1.html" height="450" width="1000" scrolling="no"></iframe> 
    <button id="button" onclick="changeLink()">Next</button> 
</body> 
</html> 
+0

당신이 어떤 오류를받을 수 있나요? 콘솔에서 아무 말도하지 않니? – BeNdErR

+0

오류 없음, 버튼을 클릭해도 아무런 변화가 없습니다 –

+0

버튼에'type = "button"''을 추가해야합니다. 그렇지 않으면 특정 브라우저에서'submit'로 작동합니다. – Jonathan

답변

0

확실하지 않습니까? 그것은 변경 한 후에는 경고 URL을 변경하는

시도는이 코드로, 클라이언트 측의 특히 JS 때문에, 정말 이상하다 :

<script> 
var x=1; 
function changeLink() 
{ 

x=x+1; 
var y="http://example.com/basicone/image"+x+".html"; 

document.getElementById('iframe-a').src=y; 
alert(document.getElementById('iframe-a').src); 
} 
</script> 

<iframe id="iframe-a" seamless src="http://example.com/basicone/image1.html" height="450" width="1000" scrolling="no"></iframe> 
<button id="button" onclick="changeLink()">Next</button> 
+0

경고 상자가 표시되지 않습니다. –

+0

@TanveerDewan 버튼을 잊어 버렸습니다. 추가 했습니까?

+0

저는 이것을 워드 프레스 사이트의 페이지에 코드로 추가하고 있습니다. 거기에서 작동하지 않습니다. 로컬 컴퓨터에서 .html로 저장 한 다음 실행하면 문제가 없습니다. –

관련 문제