3

I want to create color picker which will select color from other websites onclick in PHP web page.

I have given option to add url for reference website for color selection in my webpage. And I am opening reference url in Iframe but I am not getting color of iframe on clicking of it.

<!DOCTYPE html>
<html>
    <head>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
        <script>
          $('iframe').load(function(){   $($("iframe")[0].contentWindow).on('click', function(event) {  alert('test'); });});
        </script>
    </head>
    <body>
        <iframe id="iframe" src="http://www.theuselessweb.com/" width="500px;" height="500px">
        </iframe>
        <br>
    </body>
</html>
Samir
  • 1,312
  • 1
  • 10
  • 16
Ruta
  • 105
  • 2
  • 10
  • I don't think this is feasible? Where is your mechanism that does the color picking (even on your own page)? – Cagy79 Nov 04 '16 at 11:31
  • 1
    In same page I am getting color of canvas var position = findPos(this); var x = e.pageX - position.x; var y = e.pageY - position.y; var coordinate = "x=" + x + ", y=" + y; var canvas = this.getContext('2d'); var p = canvas.getImageData(x, y, 1, 1).data; var hex = "#" + ("000000" + rgbToHex(p[0], p[1], p[2])).slice(-6); – Ruta Nov 04 '16 at 12:10
  • Browsers are no longer allowing javascript to run on other domains (Cross-domain/Cross-origin), So i don't think this is feasible. All sites would have to include you in their Same-origin policy. Some reading on the subject: http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy – Cagy79 Nov 04 '16 at 14:51
  • I got alternate option to get colors from other website. TO get color first I am getting screenshot of entered url using google pagespeed api and from that image I am getting colors. – Ruta Nov 21 '16 at 07:06

1 Answers1

1

I got alternate option to get colors from other website. To get color first I am getting screenshot of entered url using google pagespeed api and from that image I am getting colors codes

Ruta
  • 105
  • 2
  • 10