2016-06-28 1 views
1

그래서 나는 매일 사진을 변경할 수있는 웹 사이트를 만들려고합니다. 이미지 소스를 변수 imageurl으로 설정하는 데 도움이 필요합니다. 또한 변수 imageurl이 전역이되도록합니다.변경 가능한 이미지 소스가있는 웹 사이트

변수를 imageurl 링크로 설정하고 프롬프트로 설정 한 후 이미지를 imageurl으로 설정합니다.

<!DOCTYPE html> 
<html> 

<head> 
    <div align="center"> 
     <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
     <title>picture of the day</title> 
     <h1>Jere's picture of the day</h1> 
     <link href="style.css" rel="stylesheet" type="text/css"> 
    </div> 
</head> 

<body> 
    <style> 
     div { 
      background-color: #8000ff; 
      color: #ffffff; 
      padding: 20px; 
     } 
    </style> 
    <script src="code.js" type="text/javascript" charset="utf-8"></script> 

    <script> 
     function myFunction() { 
      isitjere = prompt("Password?"); 
      if (isitjere === "thedog") 
       alert("password:" + isitjere + " " + "has been accepted"); 
      editimage = prompt("do you want to change the image?(type yes or no)"); 
      if (editimage === "yes") 
       imageurl = prompt("paste the image url(if you dont have a url for it you can upload it and paste the upload link)"); 
     } 
    </script> 
    <button onclick="myFunction()">edit</button> 
    <img src=imageurl> 
    </div> 
</body> 
</html> 
+0

작업 코드는 자바 코드를 아직 작성 당신이 실제로 있습니까? –

+0

Java 또는 Javascript? body 태그 아래 –

+0

그것은 "function myFunction()"에서 시작합니다. –

답변

0

당신의 의도 무엇을 모른다 .. 그러나 여기 :) (http://codepen.io/f7o/pen/VjpjOW)

<head> 

</head> 

<body> 
    <script> 
    function myFunction() { 
     var isitjere = prompt("Password?"); 
       if (isitjere === "thedog") 
        alert("password:" + isitjere + " " + "has been accepted"); 
       var editimage = prompt("do you want to change the image?(type yes or no)"); 
       if (editimage === "yes") 
        var imageurl = prompt("paste the image url(if you dont have a url for it you can upload it and paste the upload link)"); 
     console.log(imageurl); 
    $("#pic").attr('src',imageurl); 
    } 
    </script> 
    <button onclick="myFunction()">edit</button> 

    <div align="center"> 
    <title>picture of the day</title> 
    <h1>Jere's picture of the day</h1> 
    </div> 
    <img id="pic" src="https://www.google.com/images/nav_logo242.png"> 

</body> 

</html>