Scenario
I have created a simple iframe which i am dynamically generating from user provided HTML and CSS.
JSfiddle
https://jsfiddle.net/jaup3769/1/
Problem
Whenever I use the '#' symbol, CSS parsing is stopped beyond that point.
p#para1{
}
won't parse beyond p#
Similarly,
p{
color: green;
background-color: #ff0000;
}
won't parse beyond background-color: #
What might be the issue?
Just use encodeURIComponent instead of encodeURI. From the MDN article:
encodeURIComponentdiffer fromencodeURIin that it encode reserved characters and Number sign #
I think it even makes more sense to use it in the code you provided, since you are not encoding the whole URI, the data:whatever/charset:… part is already there…
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With