채택완료

코드가 아래와 같을때 링크 클릭 안하고 자동 실행하기

2020-10-11 (일) 19:27:53 2,574

아래처럼 코드가 되어 있을때

오픈시 " 링크클릭 "   안하고 " 열릴주소 " 가 바로 열리게 하려면 어떻게 해야 할까요?

Copy
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">

<style>
 {
  font-family: 'Lato', sans-serif;
}

.overlay {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 3; /* 바탕 보여기 여부 */
  top: 0;
  left: 0;
  background-color: rgb(0,0,0);
  background-color: rgba(0,0,0, 0.9);
  overflow-x: hidden
  transition: 0.5s;
}

.overlay-content {
  position: relative;
  top: 2%; /* 상단여백조정 */
  width: 100%;
  text-align: center;
  margin-top: 30px;
}

.overlay a {
  padding: 8px;
  text-decoration: none;
  font-size: 36px;
  color: #818181;
  display: block;
  transition: 0.3s;
}

.overlay a:hover, .overlay a:focus {
  color: #f1f1f1;
}

.overlay .closebtn {
  position: absolute;
  top: 20px;
  right: 45px;
  font-size: 60px;
}

@media screen and (max-height: 450px) {
  .overlay a {font-size: 20px}
  .overlay .closebtn {
  font-size: 40px;
  top: 15px;
  right: 35px;
  }
}
.container {
  position: relative;
  width: 90%; /* 팝업창 가로 폭 조절 */
  overflow: hidden;
  padding-top: 55%; /* 1:1 Aspect Ratio 팝업창 세로 폭 조절*/
}

.responsive-iframe {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  border: none;
}
</style>


<div id="myNav" class="overlay">
  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
  <div class="overlay-content">
  <div class="container">
  <iframe class="responsive-iframe" src="열릴주소"></iframe>
  </div>
  </div>
</div>

<span style="font-size:30px;cursor:pointer" onclick="openNav()">링크클릭</span>

<script>
function openNav() {
  document.getElementById("myNav").style.width = "100%";
}

function closeNav() {
  document.getElementById("myNav").style.width = "0%";
}
</script>
    
    
</head>
<body>
</body>
</html>
|

답변 1개

채택된 답변
+20 포인트

<script>

아래에

openNave();

이렇게 넣으세요 

답변을 작성하려면 로그인이 필요합니다.