Quotation (single quotation mark) within quotation marks in javascript and php

0

I wanted a more elegant way of writing the code below. It is passing the parameters via GET but it goes with \ 'and I can even use a PHP function of replace but wanted a solution without gambiarra. I have the following code:

onClick=\"window.parent.document.getElementById('webcam_show').src='webcam_html5/index.php?text_area=\'ta_proprietario_altera_foto64\'&frame_destino=\'frame_proprietario_foto_altera\'';window.parent.div_mostra('webcam')\"
    
asked by anonymous 18.05.2017 / 04:10

1 answer

1

One possibility would be to move the code to a function.

So your HTML might look like this:

onClick="myOnClick()"

and in JavaScript:

function myOnClick(e) {
    window.parent.document.getElementById('webcam_show').src="webcam_html5/index.php?text_area='ta_proprietario_altera_foto64'&frame_destino='frame_proprietario_foto_altera'";
    window.parent.div_mostra('webcam');
}
    
18.05.2017 / 05:57