• 09-11-2018, 18:32:19
    #1
    Merhaba php nin içindeki echo lu kısmı javascript içine yazmak istiyorum. Nasıl yapabilirim. Bir türlü beceremedim
    <p id="demo"></p>
    
    <script>
    function getScreenWidth()
    {
       var de = document.body.parentNode;
       var db = document.body;
       if(window.opera)return db.clientWidth;
       if (document.compatMode=='CSS1Compat') return de.clientWidth;
       else return db.clientWidth;
    }
    if(getScreenWidth()>800){
    document.getElementById("demo").innerHTML = 'buraya kod gelecek';
    }
    
    </script>
    echo('<script id="cid0020000202695131951" data-cfasync="false" async src="//st.chatango.com/js/gz/emb.js" style="width: 300px;height: 450px;">{"handle":"alikaanbashan","arch":"js","styles":{"a":"#17a2b8","b":100,"c":"000000","d":"000000","e":"ffffff","h":"ffffff","k":"ffccff","l":"ffccff","m":"ffccff","p":"10","q":"ffccff","r":100,"t":0,"sbc":"bbbbbb","surl":0,"cnrs":"0.35","fwtickm":1}}</script>
      <br>
         <button class="bg-info p-2 text-white rounded mr-2" type="button" onclick="myFunction()">Koyu Yeşil</button>
    		  <button class="bg-info p-2 text-white rounded mr-2" type="button" onclick="myFunctionn()">Siyah</button>
    
    		  <script>
    		  
    		  function chat() {
    		  
        document.getElementById("chat").classList.remove("sticky-top");
    }
    		  
    function myFunction() {
        document.body.style.backgroundColor = "#0B5B55";
    	document.body.style.color = "wheat";
    	document.getElementById("ust").style.backgroundColor = "#0B5B55";
    }
    			  function myFunctionn() {
        document.body.style.backgroundColor = "black";
    	document.body.style.color = "wheat";
    	document.getElementById("ust").style.backgroundColor = "black";
    }
    </script>');
  • 13-11-2018, 12:27:52
    #2
    <p>'nin içine script eklendiğini hiç görmedim daha önce, böyle bir şey olduğunu zannetmiyorum.

    Ayrıca script'i text olarak sonradan eklemeye izin verildiğinden şüpheliyim. Bunun için çeşitli workaround'lar var gördüğüm kadarıyla: https://stackoverflow.com/questions/...with-innerhtml