채택완료
td 백그라운드 자바스크립트 처리시에 익스, 크롬이 다르게 출력되네요.
td 백그라운드 자바스크립트 처리시에 익스, 크롬이 다르게 출력되네요.
Copy
<td align=center id="bgimage4"> <img src="" id="message1" width="70" height="100" /> <img src="" id="message" width="70" height="100" /> </td> <td align=center width="5%"> <div style="font-size:75px"><font color="white">:</font></div> </td><td align=center id="bgimage3"> <img src="" id="message3" width="70" height="100" /> <img src="" id="message2" width="70" height="100" /> </td> <td align=center width="5%"> <div style="font-size:75px"><font color="white">:</font></div> </td> <td align=center id="bgimage2" width="300" height="202"> <img src="" id="message5" width="60" height="100" /> <img src="" id="message4" width="60" height="100" /> </td> <script> document.getElementById( "bgimage2" ).background = bgimages; document.getElementById( "bgimage3" ).background = bgimagem; document.getElementById( "bgimage4" ).background = bgimageh; </script>
위 소스와같이 여러분들의 도움으로. 구현했습니다. 백그라운드이미지로 삽입시켜 출력하게 잘나오는데요.
문제는.... 익스플로어에서는 잘됩니다만,
크롬에서는 백그라운드 이미지가 전혀 출력이 안되네요. .
익스크롬, 둘다 되게 하는 방법이 어떤것이 있을가요? ...
도움부탁드립니다.
감사합니다.
답변 2개 / 댓글 2개
채택된 답변
+20 포인트
ysnet
2017-06-05 (월) 17:36:16
document.getElementById( "bgimage2" ).style.backgroundImage = "url('"+bgimages+"')";
답변에 대한 댓글 1개
2017-06-06 (화) 12:30:50
jquery를 사용하시면 안되는 건가요 ?
해당 작업은 비표준인데요..
답변에 대한 댓글 1개
2017-06-06 (화) 10:53:16
jquery 사용법을 모릅니다.ㅠㅠ 표준이시라면 어떻게 구현가능한지 적어주시면 공부해서 바꾸어보도록 하겠습니다.
답변을 작성하려면 로그인이 필요합니다.
[code]
<td align="center" width="20%" id="test">
<td align="center" width="20%" id="test2">
<script>
bgimages = "0.jpg";
bgimagem = "1.jpg";
document.getElementById('test').style.backgroundImage='url(' + bgimages + ')';
document.getElementById('test2').style.backgroundImage='url(' + bgimagem + ')';
</script>
[/code]
위 코드에서
document.getElementById('test').style.backgroundImage='url(' + bgimages + ')';
이것만 사용해서 출력할때는 잘됩니다.
그러나
document.getElementById('test').style.backgroundImage='url(' + bgimages + ')';
document.getElementById('test2').style.backgroundImage='url(' + bgimagem + ')';
2개를 넣어 출력할려할시에는 1개만 나오네요. 에러가 나지는 않고요.
그냥 정상적으로 test 만 출력이 됩니다. test2 는 작동안하네요.;;
조언 및 답변 부탁드립니다.
감사합니다.