I want to write an onclick function inside quotes but it throws error

$ad_div1='<div onclick="window.location="\"/"http://wwww/google.com"\"/"">xxx</div>';

How to add these quotes correctly ?

有帮助吗?

解决方案

Try with this:

$ad_div1='<div onclick="window.location=\'http://wwww/google.com\'">xxx</div>';

If you need dynamic url use,

$ad_div1='<div onclick="window.location=\''.$url.'\'">xxx</div>';
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top