javascript - Replace specific part of src attribute into an iframe element -
is there way replace specific part of src
attribute iframe
element?
i have iframe google blog working on...
<iframe allowtransparency='true' id='reactions-iframe' class='reactions-iframe' expr:src='data:post.reactionsurl' frameborder='0' name='reactions' scrolling='no'/>
when blog loads src
attribute becomes this...
src="https://www.blogger.com/blog-post-reactions.g?options=%5blike,+dislike%5d&textcolor=%23000000#http://www.blog-name.com/post-name.html"
so, when blog loads want replace part textcolor=%23000000#
textcolor=%23ffffff#
example. how can using javascript or jquery?
add onload
event iframe:
<iframe allowtransparency='true' id='reactions-iframe' class='reactions-iframe' expr:src='data:post.reactionsurl' frameborder='0' name='reactions' scrolling='no' onload='changesrc();'/>
and in changesrc()
function execute code change src value:
function changesrc() { const frame = document.getelementbyid('reactions-iframe'); frame.src = frame.src.replace('textcolor=%23000000#', 'textcolor=%23ffffff#'); }
Comments
Post a Comment