2016-07-12 2 views
0

src 속성의 특정 부분을 iframe 요소로 바꿀 수있는 방법이 있습니까?src 속성의 특정 부분을 iframe 요소로 바꿉니다.

내가 ... 내가 일하고 구글 블로그에서이 iframe이 있습니다

<iframe allowtransparency='true' id='reactions-iframe' class='reactions-iframe' expr:src='data:post.reactionsUrl' frameborder='0' name='reactions' scrolling='no'/> 

블로그는 속성이 같은이되는 src ... 그래서

src="https://www.blogger.com/blog-post-reactions.g?options=%5BLike,+Dislike%5D&textColor=%23000000#http://www.blog-name.com/post-name.html" 

때 블로그 부하를로드 할 때 부품 번호 textColor=%23000000#textColor=%23ffffff#으로 대체하고 싶습니다. 어떻게하면 자바 스크립트 또는 jQuery를 사용하여 할 수 있습니까?

<iframe allowtransparency='true' id='reactions-iframe' class='reactions-iframe' expr:src='data:post.reactionsUrl' frameborder='0' name='reactions' scrolling='no' onLoad='changeSrc();'/> 

을 그리고 changeSrc() 함수의 src 값을 변경하려면이 코드를 실행합니다 :

답변

1

당신은 iframe에 onLoad 이벤트를 추가

function changeSrc() { 

    const frame = document.getElementById('reactions-iframe'); 

    frame.src = frame.src.replace('textColor=%23000000#', 'textColor=%23ffffff#'); 

} 
관련 문제